Hi,
In one of our projects, Email messages with CSV (coma seperated text files) attachments are saved to disk for further processing. It turns out that all binary attachments are fine, but all text based attachments are corrupted by added newline characters.
Sample code:
For Each mailInfo In mailList
mailNumber = mailInfo.SequenceNumber
StatusText.Text = "Getting message: " & mailNumber.ToString() & "..."
Application.DoEvents()
SaveMessage(mailNumber, mailServer, userName, password)
mailMessage = MimeMessage.Load(_outputPath & mailNumber.ToString() & ".eml", MessageFormat.Eml)
For Each mailAttachment In mailMessage.Attachments
mailAttachment.Save(_outputPath & mailAttachment.Name)
Next
Next
The messages are saved using:
client.SaveMessage(msgNr, _outputPath & msgNr.ToString() & ".eml")
Now i have 2 questions:
- When using client.FetchMessage(msgNr) the attachments stay empty. Is there a way to directly download the message into memory, and save the attachments to disk?
- Is there any way to prevent the textbased attachments from getting corrupted with additional linebreaks? (other than zipping the text and attaching it)
Hope you can help.
Richard