Avatar of matt_karsten
matt_karstenFlag for United States of America

asked on 

VBA in Outlook - Reading Body of Email

I am putting together a small VBA script that will take certain emails that I receive in and save information into a database.  The problem I am having is stepping through the lines of the email.  The lines of the email won't necessarily come in the same order every time, so what I need to be able to do (long term) is read a line, split it, then read the first 2 characters, do some sort of conditional on it and then the processing, then read the next line and continue.

For my question, I need an example of code that simply steps through the lines of the body of the email and pops a message box with the lines one at a time.

The sample set I will be using to test with will be an email with the body:
aa:1
bb:2
cc:3
dd:4
ee:5
ff:6
gg:7
hh:8
ii:9
jj:10

So I would expect to get 10 message box with '{letters}:{number}'.  Currently I can only get it to pop a message box with the entire body, not just one line at a time.

I would prefer not to save a text file out to the c drive.  If saving the body/email to the c drive is the only answer, the text file would need to be saved with a unique name (Subject should work, the subjects are similar to "EF - Comp1") since I have 4 copies of Outlook running simultaneously on the same box.  Also, it should clean up the file after it is done.

My preference is not to save it to a file on the machine.
OutlookVisual Basic Classic

Avatar of undefined
Last Comment
matt_karsten
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of matt_karsten
matt_karsten
Flag of United States of America image

ASKER

Yeah, I sometimes am unclear however, you got me exactly what I needed to be.  I had to remove the () from strLines to get it to work, but after I did that, it worked great.

Matt
Avatar of matt_karsten
matt_karsten
Flag of United States of America image

ASKER

Thanks for the fast answer, it worked great.

Matt
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo