Author |
|
atamata Newbie
Joined: 02 April 2012
Online Status: Offline Posts: 15
|
Posted: 18 April 2012 at 7:54am | IP Logged
|
|
|
Hi,
I am running some tests and attempting to use the following code to get the first 17 characters in the body of an email (it's expected to contain a date stamp)
Dim envCol As EnvelopeCollection = imp.DownloadEnvelopes(MailBee.ImapMail.Imap.AllMessages, False, EnvelopeParts.MessagePreview, 17)
For Each env As Envelope In envCol
txtOutput.Text += env.MessagePreview.BodyPlainText
Next
This works fine and I get the date/time string except when the email has an attachment.
Could you advise what is the best way to preview the plain text in the body of an email when it has attachment(s)?
thanks
|
Back to Top |
|
|
atamata Newbie
Joined: 02 April 2012
Online Status: Offline Posts: 15
|
Posted: 18 April 2012 at 8:09am | IP Logged
|
|
|
I should add I'm using v7.1.4.357
|
Back to Top |
|
|
atamata Newbie
Joined: 02 April 2012
Online Status: Offline Posts: 15
|
Posted: 18 April 2012 at 8:49am | IP Logged
|
|
|
Hi I have it working now, I arbitrarily increased the BodyPreviewSize value to 300 and I now get what I was expecting to see in MessagePreview.BodyPlainText.
Could anyone advise why an attachment has this effect on MessagePreview.BodyPlainText?
thanks
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 19 April 2012 at 1:03am | IP Logged
|
|
|
The idea with using 17 first bytes of message text is only going to work with mail messages which have only plaintext body and no attachments. In case if there's either HTML body or attachments are found additionally, message body will actually start with something like this:
Code:
----=_NextPart_f15005c308fd8776ce5703d1e9fa5f08
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: Quoted-Printable |
|
|
Certainly, this will not be treated as a part of text body, but that's how beginning of message body looks. If those headers are there, you won't be able to reach actual plaintext body with downloading just 17 first bytes - while 300 bytes are probably going to work.
Also, if the message might contain HTML body, you might want to check that it's not before plaintext body within the message. Checking against "Content-Type: text/plain" string occurence should work for that.
--
Regards,
Igor, AfterLogic Support
|
Back to Top |
|
|
atamata Newbie
Joined: 02 April 2012
Online Status: Offline Posts: 15
|
Posted: 20 April 2012 at 1:05am | IP Logged
|
|
|
Igor wrote:
The idea with using 17 first bytes of message text is only going to work with mail messages which have only plaintext body and no attachments. In case if there's either HTML body or attachments are found additionally, message body will actually start with something like this:
Code:
----=_NextPart_f15005c308fd8776ce5703d1e9fa5f08
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: Quoted-Printable |
|
|
Certainly, this will not be treated as a part of text body, but that's how beginning of message body looks. If those headers are there, you won't be able to reach actual plaintext body with downloading just 17 first bytes - while 300 bytes are probably going to work.
Also, if the message might contain HTML body, you might want to check that it's not before plaintext body within the message. Checking against "Content-Type: text/plain" string occurence should work for that.
--
Regards,
Igor, AfterLogic Support |
|
|
Hi Thanks for your reply, it was very helpful as I am new to using your MailBee components. I have incorporated some of your suggestions into our application.
many thanks
|
Back to Top |
|
|