i configure all setting for send email using c# but when i execute than i get the following error
The requested address is not valid in its context 74.125.53.109:25
my code is
MailMessage mail = new MailMessage();
mail.To.Add("to@gmail.com");
mail.From = new MailAddress("from@gmail.com");
mail.Subject = "Test Email";
string Body = "<b>Welcome to CodeDigest.Com!!</b>";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = ConfigurationManager.AppSettings["SMTP"];
smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["FROMEMAIL"], ConfigurationManager.AppSettings["FROMPWD"]);
smtp.EnableSsl = true;
smtp.Send(mail);
Web.Config
<appSettings>
<add key="SMTP" value="smtp.gmail.com"/>
<add key="FROMEMAIL" value="mail@gmail.com"/>
<add key="FROMPWD" value="password"/>
</appSettings>
No comments:
Post a Comment