PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming reading message body line by line in VBA

Reply

reading message body line by line in VBA

 
Thread Tools Rate Thread
Old 04-12-2007, 09:35 PM   #1
Mark VII
Guest
 
Posts: n/a
Default reading message body line by line in VBA


Greetings --

I need to read the body of an email message one line at a time, much as you
would do with Line Input when reading a text file. Have code working that
opens an email item, and I can read the MailItem.Body into a string variable.
In my situation (long story), it would be easier if I could read the body as
a series of individual lines of text.

Any suggestions? TIA...

Mark
  Reply With Quote
Old 04-12-2007, 10:03 PM   #2
Ken Slovak - [MVP - Outlook]
Guest
 
Posts: n/a
Default Re: reading message body line by line in VBA

Use Split on vbCRLF if it's plain text.

Dim aryLines() As String

aryLines = Split(strBody, vbCRLF)

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Mark VII" <MarkVII@discussions.microsoft.com> wrote in message
news:0BA20B54-F87C-4D28-9C26-074236BA87E2@microsoft.com...
> Greetings --
>
> I need to read the body of an email message one line at a time, much as
> you
> would do with Line Input when reading a text file. Have code working that
> opens an email item, and I can read the MailItem.Body into a string
> variable.
> In my situation (long story), it would be easier if I could read the body
> as
> a series of individual lines of text.
>
> Any suggestions? TIA...
>
> Mark



  Reply With Quote
Old 04-12-2007, 10:07 PM   #3
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: reading message body line by line in VBA

Assuming the body has line breaks, you could read it into an array using the Split() function, then read element of the array:

arr = Split(myItem.Body, vbCrLf)
MsgBox arr(0)
etc.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Mark VII" <MarkVII@discussions.microsoft.com> wrote in message news:0BA20B54-F87C-4D28-9C26-074236BA87E2@microsoft.com...
> Greetings --
>
> I need to read the body of an email message one line at a time, much as you
> would do with Line Input when reading a text file. Have code working that
> opens an email item, and I can read the MailItem.Body into a string variable.
> In my situation (long story), it would be easier if I could read the body as
> a series of individual lines of text.
>
> Any suggestions? TIA...
>
> Mark

  Reply With Quote
Old 04-12-2007, 10:19 PM   #4
Mark VII
Guest
 
Posts: n/a
Default Re: reading message body line by line in VBA

Thanks a million for the suggestions. Just did a "quick and dirty" test with
Split, and it seems to work. I'd much rather read the array that have to
save a text file and start parsing it.

Mark
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off