| Author |  | 
      
        | ftpdaemon Newbie
 
  
 
 Joined: 26 August 2010
 Location: Uzbekistan
 Online Status: Offline
 Posts: 1
 | 
          I download an envelope:
           | Posted: 26 August 2010 at 6:28am | IP Logged |   |  
           | 
 |  
 '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 |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          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.
           | Posted: 27 August 2010 at 5:00am | IP Logged |   |  
           | 
 |  
 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 |     | 
       
       
        |  |