PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
reading message body line by line in VBA
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
reading message body line by line in VBA
![]() |
reading message body line by line in VBA |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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 |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

