Here is the C# part
for (int i = 0; i <= mailergrd.Rows.Count - 1; i++)
{
SBEmailBody.Append("<'html><'body><table><tr><td> Dear <b> <name>, </td></tr></table></b> <br/><br/> Welcome <br/>" + "hiii.<br/>"+</body></html>");
SBEmailBody.Replace("<name>", mailergrd.Rows[i]["Name"].ToString());
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "SendMail"+i, "SendMail('TO@syn.com','" + SBEmailBody.ToString() + "','Greetings from PDAC','CC@syn.com');", true);
}
Here is the JavaScript part
function SendMail(to,body,sub,cc)
{
var theApp;
var theMailItem;
var subject = sub;
var msg = body;
var carbon = cc;
try
{
var theApp = new ActiveXObject("Outlook.Application");
var theMailItem = theApp.CreateItem(0);
theMailItem.To = to;
theMailItem.Subject = (subject);
theMailItem.CC = carbon;
theMailItem.Body = (msg);
theMailItem.Display();
}
OUTPUT
<html><body><table><tr><td> JOHN <b> ,</td></tr></table></b> <br/><br/> Welcome <br/>" + "hiii.<br/>" +</body></html>
I'm trying to send E-Mails from client-side which is working fine except for the body of the mail: its not html formatted while passing from code behind.
I Think Many Questions Like these have Been Answered Before.
Return HTML from ASP.NET Web API Have a look at that and See if its a possible Solution.
您需要将HTML格式的字符串传递给MailItem.HTMLBody属性,而不是.Body。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.