Add the namespace
using System.Net.Mail;
Add this code in your button click
MailMessage msg = new MailMessage();
msg.From = new MailAddress("athi.litztech@gmail.com", "MailCoding-Server");//mail sending from
msg.To.Add("athirarajinesh@gmail.com");//mail sending to. If you want to add multiple to address separate with comma.
msg.Subject = "MailCoding-Server";
msg.Body = "Mail coding for sending mail in server";
Attachment data = new Attachment(Server.MapPath("~/TechWorld - @h!.html")); // your path may look like Server.MapPath("~/Filepath.pdf")
msg.Attachments.Add(data);
msg.Priority = MailPriority.High;//to set the priority of mail
msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("relay-hosting.secureserver.net", 25);
smtp.Send(msg);
Then you will be able to send the mail from your account and can be recieved.
No comments:
Post a Comment