c# - SMTP server requires a secure connection or the client was not authenticated. The server response was :5.5.1 authentication required -


private void button1_click(object sender, eventargs e) {     sendmaxinvoice();     try     {         mailmessage mail = new mailmessage();         smtpclient smtpserver = new smtpclient("smtp.gmail.com");         mail.from = new mailaddress("fromexample@gmail.com");         mail.to.add("toexample@gmail.com");         mail.subject = "test mail - 1";         mail.body = "mail attachment";          system.net.mail.attachment attachment;         attachment = new system.net.mail.attachment(@"c:\users\user\desktop\dee.txt");         mail.attachments.add(attachment);          smtpserver.port = 587;         smtpserver.credentials = new system.net.networkcredential("fromexample@gmail.com", "*******");         smtpserver.enablessl = true;          smtpserver.send(mail);         messagebox.show("mail send");     }     catch (exception ex)     {         console.writeline(ex.tostring());     } } 


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -