c# - SendMail in asp .net -


using system.net.mail;  protected void sendmail() {     try     {         mailmessage mail = new mailmessage();         smtpclient smtpserver = new smtpclient("smtp.google.com");         smtpserver.timeout = 30000;         smtpserver.deliverymethod = smtpdeliverymethod.network;         mail.from = new mailaddress("myemail@gmail.com");         mail.to.add("recipient@gmail.com");         mail.subject = "test";         mail.body = "test";         mail.priority = mailpriority.high;          smtpserver.port = 587;//25         smtpserver.credentials = new system.net.networkcredential("myemail@gmail.com", "pwd");         smtpserver.enablessl = true;         smtpserver.usedefaultcredentials = false;          smtpserver.send(mail);         //messagebox.show("mail send");     }     catch (exception ex)     {         //messagebox.show(ex.message.tostring());     } } 

i have not found error in code per several sources on internet. still not working out.

change gmail account access
sign in google account , redirect link
https://www.google.com/settings/security/lesssecureapps
press enable, , try code again

https://support.google.com/accounts/answer/6010255


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -