Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   reading message body line by line in VBA (http://www.outlookbanter.com/outlook-vba/62481-reading-message-body-line-line.html)

Mark VII December 4th 07 09:35 PM

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

Ken Slovak - [MVP - Outlook] December 4th 07 10:03 PM

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" wrote in message
...
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




Sue Mosher [MVP-Outlook] December 4th 07 10:07 PM

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" wrote in message ...
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


Mark VII December 4th 07 10:19 PM

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


All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com