MessageBody Html & Text empty, but BodyParts has contents

Topics: Help requests, Issues
Mar 27, 2014 at 10:13 PM
Edited Mar 27, 2014 at 10: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.

Edit:
If I forward an identical message and attachment from another gmail account, MessageBody populates as expected.
Coordinator
Mar 28, 2014 at 9: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?

Greets,

Pavel
Apr 3, 2014 at 10: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,

Ted
Coordinator
Apr 8, 2014 at 7: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,

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

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.

Thanks,

Ted
Coordinator
Apr 10, 2014 at 7: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.

Thanks,

Pavel
Apr 10, 2014 at 2: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.

Ted
Coordinator
Apr 10, 2014 at 9: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.

Greets,

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

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

Ted