Login  
Search All Forums
Dart Home | PowerTCP Mail for .NET | Custom Development Reply | PowerTCP Mail for .NET Topics | Forums   
AuthorForum: PowerTCP Mail for .NET
Topic: Yahoo Mail and IMAP - Unexpectedly Empty Messages Fix
Nick B (Admin)

From: Utica, NY USA
Posts: 619
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted February 1, 2017 2:00 PM

It was recently brought to our attention that emails downloaded with our Imap class from Yahoo Mail fail to parse correctly, resulting in empty Text, Html, and other properties. It appears that Yahoo Mail has made a recent change (terminating message lines with only a LF, instead of a CRLF), resulting in RFC non-compliant responses, breaking our parsing. We've reported this to Yahoo Mail, and the following static method can be used as a workaround (as a substitute for ImapMessage.Get()) until that is fixed:

/// <summary>
/// Downloads the specified ImapMessage and corrects the line terminator from LF to CRLF.
/// </summary>
/// <remarks>Use instead of ImapMessage.Get() for relevantly non-compliant servers</remarks>
static void getMessage_FixLineTerminator(ImapMessage msg)
{
 using (MemoryStream ms = new MemoryStream())
 {
 msg.Get(ms, ImapMessageInfo.Message);
 msg.Message = new MailMessage(System.Text.ASCIIEncoding.ASCII.GetString(ms.ToArray()).Replace("\n", "\r\n"));
 }
}

As a more general fix that should work against all servers (instead of only against non-compliant servers), this may be substituted for the last line of code above:

msg.Message = new MailMessage(System.Text.ASCIIEncoding.ASCII.GetString(ms.ToArray()).Replace("\r\n", "\n").Replace("\n", "\r\n"));
Reply | PowerTCP Mail for .NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX