Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The code to send emails with gmail smtp server doesn't seem to working

What I have tried:

Web.config

system.net
mailSettings
smtp deliveryMethod="Network" from="***"
network host="smtp.gmail.com" port="587" userName="***" password="***"
smtp
mailSettings
system.net

aspx.cs

SmtpClient smptclient = new SmtpClient();
MailMessage message = new MailMessage();
message.To.Add(new MailAddress(txtEmail.Text.ToString()));
message.Subject = "Welcome to XcellIT";
message.Body = "Thank you for joining XcellIT";
smptclient.Send(message);
Posted
Updated 12-Jul-16 2:54am
Comments
Michael_Davies 12-Jul-16 8:36am    
Gmail requires encryption, smtpclient.EnableSsl = true. May help, if not there are lots of questions on the subject on this site.
thecoderques 12-Jul-16 8:48am    
Should smtpclient.EnableSsl = true be on the web.config or aspx.cs file?
Suvendu Shekhar Giri 12-Jul-16 8:43am    
What is the error you are getting?
thecoderques 12-Jul-16 8:49am    
No error,just not working
F-ES Sitecore 12-Jul-16 8:49am    
This is one of the most frequently asked questions, please do basic research before asking a question like using google. There are loads of examples out there about how to do this and issues you might have. The ultimately answer, however, is to not send email through gmail, use the smtp server provided by your host.

http://forums.asp.net/post/5825785.aspx

1 solution

refer this for coding part: sending email to gmail from asp.net[^]

and this for enabling gmail via apps I want to send mail using gmail account[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900