This is code for send mail through gmail sever. with web config setting and namespaces
public static bool SendPwdInfo(string name, string pwd, string EmailTo)
{
try
{
MailMessage message = new MailMessage();
message.From = new MailAddress("info@helpondesk.com");
message.To.Add(EmailTo.Trim());
message.Subject = "Your Password!";
string MailFormat = "
your login information is as follows - |
User name: "+name + ""; MailFormat += " |
Password: " + pwd + " |
message.Body = MailFormat;
message.IsBodyHtml = true;
message.Priority = MailPriority.High;
//SmtpClient client = new SmtpClient();
//client.Host = "mail.a1technology.com";
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
NetworkCredential mailAuth = new NetworkCredential("helpondesk@gmail.com", "abcdef");
client.EnableSsl = false;
client.UseDefaultCredentials = false;
client.Credentials = mailAuth;
client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
client.Send(message);
return true;
}
catch
{
return false;
}
}
name space
//--------------------------------
using System.Net.Mail;
using System.Net;
Webconfig setting
Thanks
Helpondesk Team.
No comments:
Post a Comment