简体   繁体   中英

Emails (from asp.net System.Net.Mail) Truncating in Outlook but not Gmail

We're running an older ASP.NET 2.5 application and we use the System.Net.Mail namespace to send plaintext emails to customers. Some are a bit long because we send lists of products that are being changed to our clients.

We're getting reports from our users that their emails are cutting off. After some investigation we realized that they're only cut off in Outlook. In Gmail they're fine. Any idea what this could be?

Here is a stripped out sample of the code generating our emails...

MailMessage msg = new MailMessage();
SmtpClient client = new SmtpClient(ConfigurationManager.AppSettings["smtpHost"], Convert.ToInt16(ConfigurationManager.AppSettings["smtpPort"]));
client.Credentials = new    NetworkCredential(ConfigurationManager.AppSettings["smtpCredentialUser"], ConfigurationManager.AppSettings["smtpCredentialPassword"]);

msg.From = new MailAddress("xxx@xxxx.xxx", "Product Alert");
string Message_Subject = "Product Alerts";

string body = "\nThe following Products have been updated" + "\r\n\r\n";
    foreach (ProductItem pi in prods.updatedItems)
    {
        body += "Product Name: " + pi.Name.ToString() + "\n";
        body += "New Price   : " + pi.Price.ToString() + "\n";
    }

msg.Body = body;
msg.To.Add(new MailAddress("xxx@xxx.xxx","Mr. Test");

client.Send(msg);

The problem may be related to some "special-code" character inside your text, causing Outlook to understand EOF or something like that.

Try to specify the BODYFORMAT as PLAINTEXT.

      msg.bodyformat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatPlain

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM