reading message body line by line in VBA

M

Mark VII

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
 
K

Ken Slovak - [MVP - Outlook]

Use Split on vbCRLF if it's plain text.

Dim aryLines() As String

aryLines = Split(strBody, vbCRLF)
 
S

Sue Mosher [MVP-Outlook]

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.
 
M

Mark VII

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top