Parts of an email message
The message headers contain information concerning the sender and recipients. The exact content of mail headers can vary depending on the email system that generated the message. Generally, headers contain the following information:
Date and time received (On).
Recipient email address.
The body of a message contains text that is the actual content, such as "Employees who are eligible for the new health care program should contact their supervisors by next Friday if they want to switch." The message body also may include signatures or automatically generated text that is inserted by the sender's email system.
Attachments are optional and include any separate files that may be part of the message.
In the SMTP standard, the body is the full email message. The header here is only information servers need to deliver the message.............
To implement this concept first create new web application >> Right click on your application >> Select Add New item >> Select HTML Page and click OK
Then after add what you want to show in body part of email code as per it into your HTML Page.
here i want to show 4 paramaters,
for get value of dynamically of this four parameters,we have to use this methos.
protected void getDataforemail()
EventManagerDataContext db = new EventManagerDataContext();
var q = (from a in db.EMR_EVENTs
join b in db.EMR_CLIENTs on a.ClientID equals b.ClientID
EventID = a.EventID,
Client_Name = b.Name,
Event_Name = a.Name,
now you have to call this function only.and you will get value of this parameters dynamically from database.
now put this code into your aspx.cs file.
protected void getDynamicbodyforemail()
StreamReader reader = new StreamReader(Server.MapPath("~/HTMLPage1.htm"));
string readFile = reader.ReadToEnd();
string myString = "";
myString = readFile;
myString = myString.Replace("$$Client_Name$$", Client_Name);
myString = myString.Replace("$$Event_Name$$", Event_Name);
myString = myString.Replace("$$Event_Id$$", EventID);
myString = myString.Replace("$$Activation_Code$$", "http://www.Italiyainternational.blogpost.com");
MailMessage Msg = new MailMessage();
MailAddress fromMail = new MailAddress("firstname.lastname@example.org");
// Sender e-mail address.
Msg.From = fromMail;
// Recipient e-mail address.
// Subject of e-mail
Msg.Subject = "Send Mail with HTML File";
Msg.Body = myString.ToString();
Msg.IsBodyHtml = true;
var smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromMail.ToString(), "your password");
smtp.Timeout = 20000;