Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: Issues with CRLF in headers Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
ftpdaemon
Newbie
Newbie


Joined: 26 August 2010
Location: Uzbekistan
Online Status: Offline
Posts: 1
Posted: 26 August 2010 at 6:28am | IP Logged Quote ftpdaemon

I download an envelope:

'VB.NET syntax

Protected m_imapSource As Imap
Protected m_imapDestination As Imap

imEnvelope = m_imapSource.DownloadEnvelopes("1", False, EnvelopeParts.All, -1)(0)

then I upload the message to another IMAP account:

m_imapDestination.UploadMessage(imEnvelope.MessagePreview, fDestFolderName, imEnvelope.Flags.ToString(), imEnvelope.DateReceived)

but on some messages the upload fails, as the receiving IMAP server apparently gets confused from the CRLF contained in the message headers, and assumes the APPEND command is over, as per http://www.faqs.org/rfcs/rfc3501.html:

--- QUOTE STARTS ---
All interactions transmitted by client and server are in the form of
   lines, that is, strings that end with a CRLF.
--- QUOTE ENDS ---

The simple solution is to convert the headers as either:

imEnvelope.MessagePreview.EncodeAllHeaders(Encoding.ASCII, HeaderEncodingOptions.Base64)

or:

Dim x As Integer
Dim v As String

For x = 0 To imEnvelope.MessagePreview.Headers.Count - 1
     v = imEnvelope.MessagePreview.Headers(x).Value
     imEnvelope.MessagePreview.Head ers(x).Value = v.Replace(vbCrLf.ToString, vbLf.ToString)
Next

It seems that DownloadEnvelopes(...) is converting LF to CRLF, which is causing the problem.

Is there any way that the downloaded message headers are NOT converted (i.e. LF stays LF, not CRLF), or am I missing something?

Of course, that issue is NOT present when using Outlook/Outlook Express/what have you, to copy the message(s) between two IMAP accounts.

Sincerely,

Johnny
Back to Top View ftpdaemon's Profile Search for other posts by ftpdaemon
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 27 August 2010 at 5:00am | IP Logged Quote Alex

Single LF is not a valid character in MIME. Some servers erroneously send emails where some lines end with LF, not CRLF. MailBee.NET has a workaround for that to automatically replace such LF with CRLF.

Anyway, APPEND command ends not with CRLF. If it were so, it would not be possible to upload any emails because all emails contain CRLFs. Instead, APPEND command sends the number of bytes which will then be sent, and then sends the chunk of the data of the specified length (and it does not matter what is in this data).

I did not understand what exactly happens in your case but it certainly has nothing to do with the presence of CRLF (which is always present in emails).

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide