.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

NewLine MSg Body

Posted By: Aamrapali Tamgadge     Posted Date: January 28, 2011    Points:2   Category :ASP.Net
hi..Wen m sending mail my body text is like below,,but i want to print text in newline after some words like after Name,After Mobile No.

Can Anyone Help me out..

Email :amy.1by88@gmail.com Name:dghd Mobile No:5555555555 Address: ghdh AP-Anantapur Enquiry Message:</brdsfsf

Responses
Author: Shruthi BM          Accepted Answer   
Posted Date: January 28, 2011     Points: 10   

Hi Aamrapali,

Its better to use table format in order to send any details in message body which looks good. Please find the below code which i have used in my project.

StringBuilder str = new StringBuilder();
str.AppendLine("<html><body><table border='5' cell padding='8' cellspacing='5' width='50%'>");
str.AppendLine("<tr>");
str.AppendLine("<th colspan='5' bgcolor='Pink'>REQUESTED DETAILS BY " + "" + displayname.Text + "</th>");
str.AppendLine("</tr");
str.AppendLine("<tr>");
str.AppendLine("<th bgcolor='#A5BBD3'>FirstName</th><th bgcolor='#A5BBD3'>LastName</th><th bgcolor='#A5BBD3'>DisplayName</th><th bgcolor='#A5BBD3'>Groups Requested</th><th bgcolor='#A5BBD3'>OU</th>");
str.AppendLine("</tr>");
str.AppendLine("<tr>");
str .AppendLine ("<td>"+firstname .Text +"</td>"+"<td>"+lastname .Text+"</td>" +"<td>"+displayname .Text+"</td>"+"<td>"+ Label6 .Text +"</td>"+"<td>"+DropDownList1 .SelectedItem .Text +"</td>");
str.AppendLine("</tr>");
str.AppendLine("</table></body></html>");
string table = str.ToString();

MailMessage mail = new MailMessage();
com.CommandText = "select ApproverEmail from tablename where colname='" + approveremail.Text + "'";
dr = com.ExecuteReader();
while (dr.Read())
{
mail.To = dr["ApproverEmail"].ToString();
}
mail.From = "xxxx@xxx.com";
mail.Cc = emailid.Text;
mail.Subject = "User Creation Requested Notification :" + "" + displayname .Text + " " + "Waiting For Approval";
mail.BodyFormat = MailFormat.Html;
mail.Body = "Hi " + approveremail.Text + "," + "<br>" + "<br>" + "Requestor has requested for new user creation with following details." + "<br>" + "<br>" + " Click Here to Login <a href=http://localhost:xxxxxxxxx/.aspx> Click here</a>" + "<br>";
mail.Body = mail.Body + table;
mail.Priority = MailPriority.High;
SmtpMail.SmtpServer = "localhost";
try
{
SmtpMail.Send(mail);
Label5 .Text =("Your User Creation details has been sent sucessfully for Approval -Thank You");
}


catch (Exception exc)
{
Response.Write("Send failure: " + exc.ToString());

}

}
con.Close();

Regards,
Shruthi BM

Author: Aamrapali Tamgadge             
Posted Date: January 28, 2011     Points: 5   

Hi.. Shruthi Thanks..I have use your code and its working..

Software Programmer At OTIS ISRC


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend