Send Email with attachment In Asp .Net with c#
string filePath ="C:\\abc.doc";
string senderEmailid="senderemailid@gmail.com";
string senderPassword="password";
string recieverEmailid="recievermailid@gmail.com";
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential(senderEmailid, senderPassword),
EnableSsl = true
};
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(senderEmailid, recieverEmailid);
mail.Attachments.Add(new Attachment(Server.MapPath(filePath)));
mail.Subject ="Subject of Mail"
mail.Body ="<b>Hai</b>";
mail.IsBodyHtml = true; // To make html
client.Send(mail);
string filePath ="C:\\abc.doc";
string senderEmailid="senderemailid@gmail.com";
string senderPassword="password";
string recieverEmailid="recievermailid@gmail.com";
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential(senderEmailid, senderPassword),
EnableSsl = true
};
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(senderEmailid, recieverEmailid);
mail.Attachments.Add(new Attachment(Server.MapPath(filePath)));
mail.Subject ="Subject of Mail"
mail.Body ="<b>Hai</b>";
mail.IsBodyHtml = true; // To make html
client.Send(mail);
I read this article,Asp.net provides a email service to send mail easily.thanks for sharing valuable post.
ReplyDeleteWelcome Burke Hayness...
Delete