The following code sample shows how to write a reusable class for Sending Emails using ASP.Net 2.0
public class EmailClass { public static string SendEmail ( string from, string name, string emailIdTo, string subject, string body ) { SmtpClient smtpClient = new SmtpClient (); MailMessage mailMessage = new MailMessage (); MailAddress mailAddress = new MailAddress ( from, name ); smtpClient.Host = "localhost"; smtpClient.Port = 25; mailMessage.From = mailAddress; mailMessage.To.Add ( emailIdTo ); mailMessage.Subject = subject; mailMessage.IsBodyHtml = false; mailMessage.Body = body; smtpClient.Send ( mailMessage ); return "Successfully Mail Sent"; } }
|
| Author: Siva Prasad 23 May 2008 | Member Level: Gold Points : 2 |
Helo Rajesh,
I am sending one text file , it will solve the problem
Rajesh Send Email.txt |