加号有问题,它在发送电子邮件后转换为 ascii
Having problem with plus sign, it converts into ascii after sending email
当运行以下代码时脚本部分<script type="application/json+trustpilot">
转换为<script type="application/json+trustpilot">
。
如果 isBodyHTML 设置为 false 加号正确显示(意味着不显示 +
)但不是 HTML 格式(这是需要的)。
有没有其他人遇到过类似的问题?
我正在 SSIS 2012 项目中使用 C# 执行此操作。
已经尝试过所有的编码格式,比如 default, unicode, ...
private void sendEmail(string SendMailTo, string SendMailSubject, string SendMailBody)
{
string sqldbaEmail = "myemail@mail.com";
string newSqldbaEmail = "anotheremail@mail.com";
// email sender hardcoded because cannot send email with other credentials
MailMessage myHtmlFormattedMail = new MailMessage(sqldbaEmail, newSqldbaEmail, SendMailSubject, "");
myHtmlFormattedMail.BodyEncoding = System.Text.Encoding.UTF8;
myHtmlFormattedMail.Body = SendMailBody;
myHtmlFormattedMail.Bcc.Add(SendMailTo);
myHtmlFormattedMail.IsBodyHtml = true;
// Create a SMTP client to send the email
SmtpClient mySmtpClient = new SmtpClient();
NetworkCredential basicCredential = new NetworkCredential(sqldbaEmail, "password");
mySmtpClient.Port = 25;// 587;//2525; // If you want to use a different portnumber instead of the default. Else remove this line.
mySmtpClient.Host = "smtp.office365.com";
mySmtpClient.UseDefaultCredentials = false;
mySmtpClient.Credentials = basicCredential;
mySmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mySmtpClient.EnableSsl = true;
// Sends email
mySmtpClient.Send(myHtmlFormattedMail);
}
感谢观看。
这有帮助吗?
"Adding {scripts}{/scripts} before the opening tag keeps the
code there."
当运行以下代码时脚本部分<script type="application/json+trustpilot">
转换为<script type="application/json+trustpilot">
。
如果 isBodyHTML 设置为 false 加号正确显示(意味着不显示 +
)但不是 HTML 格式(这是需要的)。
有没有其他人遇到过类似的问题?
我正在 SSIS 2012 项目中使用 C# 执行此操作。 已经尝试过所有的编码格式,比如 default, unicode, ...
private void sendEmail(string SendMailTo, string SendMailSubject, string SendMailBody)
{
string sqldbaEmail = "myemail@mail.com";
string newSqldbaEmail = "anotheremail@mail.com";
// email sender hardcoded because cannot send email with other credentials
MailMessage myHtmlFormattedMail = new MailMessage(sqldbaEmail, newSqldbaEmail, SendMailSubject, "");
myHtmlFormattedMail.BodyEncoding = System.Text.Encoding.UTF8;
myHtmlFormattedMail.Body = SendMailBody;
myHtmlFormattedMail.Bcc.Add(SendMailTo);
myHtmlFormattedMail.IsBodyHtml = true;
// Create a SMTP client to send the email
SmtpClient mySmtpClient = new SmtpClient();
NetworkCredential basicCredential = new NetworkCredential(sqldbaEmail, "password");
mySmtpClient.Port = 25;// 587;//2525; // If you want to use a different portnumber instead of the default. Else remove this line.
mySmtpClient.Host = "smtp.office365.com";
mySmtpClient.UseDefaultCredentials = false;
mySmtpClient.Credentials = basicCredential;
mySmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
mySmtpClient.EnableSsl = true;
// Sends email
mySmtpClient.Send(myHtmlFormattedMail);
}
感谢观看。
这有帮助吗?
"Adding {scripts}{/scripts} before the opening tag keeps the code there."