This project is read-only.

MessageBody Html & Text empty, but BodyParts has contents

Topics: Help requests, Issues
Mar 27, 2014 at 11:13 PM
Edited Mar 27, 2014 at 11:17 PM
Using ImapX2 on GMail with a message body and one attachment, I am trying to read the message body.

MessageBody.Html and .Text are both false and Html & Text are both empty, although BodyParts[0].ContentStream has the email body content and BodyParts[1].Content stream has what appears to be the binary attachment.

Will BodyParts[0] always contain the text message or should I take a different approach?

I am using MessageFetchMode.Full.

If I forward an identical message and attachment from another gmail account, MessageBody populates as expected.
Mar 28, 2014 at 10:39 AM
Hi Alien_Technology,

I think the problem is in the ContentType of the body part not being determined right.

Can you check the Parameters property of the body part and see if it contains a value for the ContentType and which it is?


Apr 3, 2014 at 11:33 PM
Hi Pavel,

BodyParts[0].Parameters.Count = 1 and Parameters[0].Key = "charset".

If it is helpful, BodyParts[0].ContentType={text/plain; charset=US-ASCII}

Thank you for the assistance and great library,

Apr 8, 2014 at 8:18 PM
Good evening!

Please have a look at the latest code in the repository. Various fixes have been done. I'd be happy if you can test it and give some feedback!

Best regards,

Apr 9, 2014 at 7:41 PM
Using code downloaded on 25014-04-09 with assembly version

We have made progress, but are not quite there. The message.Body now correctly has:
HasText = true
Text = <body of message>

Subject is still null.

Although I don't need them for this project, Date, From,, ReplyTo, Sender, TextBody and To are also null.

The messages are changed when forwarded, so forwarding one to you probably won't help. They are generated by a vendor every 10 minutes. If it would help I can have some messages sent to a temporary gmail account and send you the login info.


Apr 10, 2014 at 8:49 AM
Hi Ted,

first of all, the properties Date, From, ReplyTo, Sender and To are set based on the headers being fetched. If they're null, I'm sure you have configured the client not to fetch them. Check the client.Behavior.MessageFetchMode and the client.Behavior.RequestedHeaders.

The property Message.TextBody is deprecated and should not be used, please use Message.Body.Text instead.

It wouldb be really helpful if you can send the messages to a temporary account, so I can test it.


Apr 10, 2014 at 3:47 PM
Hi Pavel,

I have set up a new test gmail account that with a few sample messages. The username is imaptest101 and pw is 20141234. There is no sensitive information in the email.

Apr 10, 2014 at 10:09 PM
Hi Ted,

have you tested the latest code with this account? I just logged in throught the sample application, and the issue doesn't occur in any of the messages.


Apr 10, 2014 at 11:43 PM
Hi Pavel,

My humble apologies. While trying different things, I left the MessageFetchMode at BodyStructure. Very embarrassing. All good now.