Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 加号有问题,发送电子邮件后会转换为ascii码_C#_Html Email - Fatal编程技术网

C# 加号有问题,发送电子邮件后会转换为ascii码

C# 加号有问题,发送电子邮件后会转换为ascii码,c#,html-email,C#,Html Email,运行以下代码时,脚本部分将转换为。 如果isBodyHTML设置为false,则加号将正确显示(表示不显示+;),但不会以HTML格式显示(这是必需的) 还有其他人有类似的问题吗 我在SSIS 2012项目的C#中做这件事。 已经尝试了所有编码格式,如默认、unicode、 private void sendEmail(string SendMailTo, string SendMailSubject, string SendMailBody) { string sqldbaEma

运行以下代码时,脚本部分将转换为
。 如果isBodyHTML设置为false,则加号将正确显示(表示不显示
+;
),但不会以HTML格式显示(这是必需的)

还有其他人有类似的问题吗

我在SSIS 2012项目的C#中做这件事。 已经尝试了所有编码格式,如默认、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);
}

谢谢您的关注。

这有帮助吗

“在开始标记之前添加{scripts}{/scripts}将保留 在那里编码。”


脚本部分
什么脚本,我在代码中没有看到?您是否尝试过设置内容类型,例如:
?请显示
SendMailBody
数据。。。但这肯定是一个编码问题。