Search code examples
gmailimapmailkit

Using Mailkit to download email from google as plain/text broke line every 78(maybe) character


I'm making an project working with gmail. Basically i need to download the mail content and for this i'm using Mailkit. But by saving email text the final result give me line breaks after some characters.

I google it so i know that is intenet feature using RFC2822.

This is the code i use to download the email to a txt file.

var items = client.Inbox.Fetch(0, -1, MessageSummaryItems.UniqueId | MessageSummaryItems.BodyStructure);

foreach (var item in items)
{
    if (item.TextBody != null)
    {
    var mime =(TextPart)client.Inbox.GetBodyPart(item.UniqueId,item.TextBody);
    var text = mime.Text;
    File.WriteAllText("textTest.txt", text);
    }
}

Is there any way to continue line instead of break it ? Or i just look the problem from the wrong way ?


Solution

  • The line wrapping is done by either the sender or his mail client. It is not done by MailKit's ImapClient.