A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

reading message body line by line in VBA



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 4th 07, 09:35 PM posted to microsoft.public.outlook.program_vba
Mark VII
external usenet poster
 
Posts: 6
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
  #2  
Old December 4th 07, 10:03 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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



  #3  
Old December 4th 07, 10:07 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default 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

  #4  
Old December 4th 07, 10:19 PM posted to microsoft.public.outlook.program_vba
Mark VII
external usenet poster
 
Posts: 6
Default 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
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to preserve line breaks in the message Igor S Outlook - General Queries 4 December 11th 07 02:04 AM
Is is possible to change the body line size? eran kaufman Outlook - General Queries 0 June 27th 07 09:56 AM
Reply in Outlook cursor on TO line instead of body of message [email protected] Outlook - General Queries 0 June 27th 06 09:21 PM
See attachment line in new message? cjlatta Outlook - Installation 1 June 15th 06 11:16 PM
How to input line break in the body of an email defined in vb. Xluser@work Outlook and VBA 1 February 22nd 06 02:20 PM


All times are GMT +1. The time now is 12:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.