using System.Net.Mail To send smtp mail via google gets me a time out exception.
Posted
by Anicho
on Stack Overflow
See other posts from Stack Overflow
or by Anicho
Published on 2010-04-16T10:42:57Z
Indexed on
2010/04/16
10:53 UTC
Read the original article
Hit count: 599
Hey guys, I guess I got another asp.net question I am trying to send email using smtp authentication through google but I am constantly getting a timed out error and no idea what it might be from the following code its not my firewall or my isp blocking smtp ports so its most probably the code:
MailMessage msg = new MailMessage();
String BodyMsg;
BodyMsg = "Hey " + TxtBoxUsername.Text + "@" + "Welcome to Tiamo your username and password are:@Username: "
+ TxtBoxUsername.Text + "@Password: " + PasswordString + "@You have succesffully registered, you can now login."
+ "@Thank You@Tiamo Team";
BodyMsg = BodyMsg.Replace("@", System.Environment.NewLine);
msg.To.Add(new MailAddress(TxtBoxEmail.Text));
msg.From = new MailAddress("[email protected]");
msg.Subject = "Re: Welcome to Tiamo";
msg.Body = BodyMsg;
SmtpClient client = new SmtpClient() ;
client.EnableSsl = true;
client.Send(msg);
and this is my web.config email smtp settings:
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="smtp.gmail.com" port="465" userName="[email protected]" password="MyLovelyPassword" defaultCredentials="true"/>
</smtp>
</mailSettings>
Im completely exhausted so I thought the best thing is to pop up a question, hope you can help it will all be much appreciated... thanks anicho.
© Stack Overflow or respective owner