[英]How to pass HTML formatted email body to a javascript function using asp.net c#
Here is the C# part 这是C#部分
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 这是JavaScript部分
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. 我正在尝试从客户端发送电子邮件,除了邮件正文以外,它都工作正常:从背后的代码传递时,其格式不是html格式。
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. 从ASP.NET Web API返回HTML。看看它是否可行。
您需要将HTML格式的字符串传递给MailItem.HTMLBody属性,而不是.Body。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.