SendMail method (using Charp)
The following function send mail to particular mail ID just check it out the following code:
public static void SendMail(string from, string to, string subject, string body, Stream attachment) { MailMessage mailMsg = new MailMessage(); mailMsg.From = new MailAddress(from); mailMsg.To.Add(to); mailMsg.Subject = subject; mailMsg.IsBodyHtml = true; mailMsg.BodyEncoding = Encoding.UTF8; mailMsg.Body = body; mailMsg.Priority = MailPriority.Normal;
//Message attachment if (attachment != null) mailMsg.Attachments.Add(new Attachment(attachment, "veera.text"));
// Smtp configuration SmtpClient client = new SmtpClient(); client.Credentials = new NetworkCredential("", ""); client.Port = 25; client.Host = "localhost"; client.EnableSsl = false;
MailMessage message = mailMsg; client.Send(message); }
|
| Author: Mohan 03 Sep 2009 | Member Level: Diamond Points : 0 |
What is MailMessage?? I Need to Add any Namespace for this??
|
| Author: Ramesh Sahu 03 Sep 2009 | Member Level: Gold Points : 1 |
Hi, U schould show Imports System.Net.Mail and Setting in Web Config how to call SMTP services
|