reading message body line by line in VBA

  • Thread starter Thread starter Mark VII
  • Start date Start date
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
 
Use Split on vbCRLF if it's plain text.

Dim aryLines() As String

aryLines = Split(strBody, vbCRLF)
 
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.
 
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
 
Back
Top