Saturday, 22 December 2012 14:55

how to send mail from .net

Written by 
Rate this item
(0 votes)

beginners of .net programming can't guess sometime that
how easy is sending mail through .net.there are many ways
to do that.but i am writing here the easiest method to send
mail in c# with .net.It doesn't involve a lot's of coding.
all is built in and no more components.

the format for that can be System.Web.Mail.MailFormat.Text
or a alternative - System.Web.Mail.MailFormat.Html.

following static function shows how to send mail easily.

public static void Email(string To_Address, string
From_Address, string Email_Subject, string Email_Body,
System.Web.Mail.MailFormat Format){
System.Web.Mail.MailMessage Sender = new
System.Web.Mail.MailMessage();
Sender.From = From_Address;
Sender.To = To_Address;
Sender.Subject = Email_Subject;
Sender.Body = Email_Body;
Sender.BodyFormat = Format;
System.Web.Mail.SmtpMail.Send(Sender);
}

integrate it in your program with all the fields and enjoy.

Read 1502 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
Login to post comments