0 votes

Hello, I'm trying to read the whole email body from each email on Gmail inbox. So far I can get all emails from inbox, but when I try to read the body using

Dim currentEmail As IMail = New MailBuilder().CreateFromEml(email.GetMessageByUID(uid))
currentEmail.Text

I can't get the whole body text. Please help.

by

1 Answer

0 votes

Imap.GetMessageByUID downloads entire email from the IMAP server (all headers, entire body, all attachments).

It is impossible for IMail.Text to contain only a fragment of the actual email body.

Email message can have its body stored in several formats. In most cases those are HTML (IMail.Html) and plain text (IMail.Text), so please also examine IMail.Html property.

Both formats should contain exactly the same data (with different formatting of course). You must have in mind, that there is no mechanism to force sender to comply to this. That means, that an incorrect email client is able to send a message, that has different content in text/plain part and different content in text/html. It is very unlikely though.

Please save this mail as raw eml file to disk and examine it carefully. If you believe that Mail.dll somehow truncates, what you can find in the raw eml email file (very unlikely), please let us know.

by (297k points)
Thanks for your answer. I have downloaded the eml file, using IMail.Text I'm just getting the first part of the message, after "This is a MIME-formatted message. Portions of this message may be unreadable without a MIME-capable mail program." and nothing more.
Using IMail.HTML I'm getting no text.
If the message consists of more that one visual part with text/plain content (this email was probably sent by Apple device), you'll have to use IMail.Visuals to get those other parts.

IMail.Visuals collection contains MIME parts that email client should display to the user when he/she opens an email message. Usually it contains images, that are embedded in a HTML email. Apple devices however are known for splitting message text, when user adds an image. In such case IMail.Visuals contains MimeText class instances, that contain rest of the text, and MimeData instances representing images.
...