Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: DownloadEnvelopes and attachments Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
atamata
Newbie
Newbie


Joined: 02 April 2012
Online Status: Offline
Posts: 15
Posted: 18 April 2012 at 7:54am | IP Logged Quote atamata

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 View atamata's Profile Search for other posts by atamata
 
atamata
Newbie
Newbie


Joined: 02 April 2012
Online Status: Offline
Posts: 15
Posted: 18 April 2012 at 8:09am | IP Logged Quote atamata

I should add I'm using v7.1.4.357
Back to Top View atamata's Profile Search for other posts by atamata
 
atamata
Newbie
Newbie


Joined: 02 April 2012
Online Status: Offline
Posts: 15
Posted: 18 April 2012 at 8:49am | IP Logged Quote atamata

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 View atamata's Profile Search for other posts by atamata
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 19 April 2012 at 1:03am | IP Logged Quote Igor

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 View Igor's Profile Search for other posts by Igor
 
atamata
Newbie
Newbie


Joined: 02 April 2012
Online Status: Offline
Posts: 15
Posted: 20 April 2012 at 1:05am | IP Logged Quote atamata

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 View atamata's Profile Search for other posts by atamata
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide