johngalt47
08-05-2014, 04:12 PM
I know how to program the basics of VBA but my problem is how to create an effective algorithm that works for various situations. For example, my current problem is how to process the text of emails of the following form:
1. The emails are inconsistent in the number of lines and the data.
2. The first word following the first line consisting of double dashes can be either DRAWING, DOCUMENT, ISO or TAG
3. I want to extract the rows of data like 'RV-99200" below.
4. What I have tried to do is something like
msglines = split(item.body,vbcrlf)
for each msgline in msglines
strings = split(msgline," ")
if strings(0) = "TAG" then
do one thing
else if strings(0) = "=" then
do something else
etc, etc
It just isn't working for me so I'm wondering if someone has a better strategy.
TIA
"To view this electronic transmittal and its electronic documents, click the link below.
--
--
-------------------------------------------------------------
EVERYTHING below is a text representation of the link supplied above.
-------------------------------------------------------------
XXX Job Number: E0886 Client Job Number: C71024
C71024 SHU PROJECT EXECUTE
INQUIRY REQ TO PROCUREMENT PIMS REF #: 619 was Issued on 07/17/14 From Job Number: E0886
REQUISITION NBR: I0009 REV:
GLOBAL TRANS. #: 619
--------------------------------------------------------------------------------------------------------------------------
Transmittal Description:
RELIEF VALVES - I0009
--------------------------------------------------------------------------------------------------------------------------
Transmittal Caption:
The listed Inquiry Requisition is hereby transmitted to Purchasing. Please issue
an Inquiry to the listed vendors.
--------------------------------------------------------------------------------------------------------------------------
Remarks:
=============================================================
TAG TAG TAG TAG TAG TAG
--------------------------------------------------------------------------------------------------------------------------
RV-99200
RV-99203
RV-99204
RV-99205
RV-99206
=============================================================
D I S T R I B U T I O N 4.3*
XXX XXXXX
-------------------------------------------------- --------------------------------------------------
1. The emails are inconsistent in the number of lines and the data.
2. The first word following the first line consisting of double dashes can be either DRAWING, DOCUMENT, ISO or TAG
3. I want to extract the rows of data like 'RV-99200" below.
4. What I have tried to do is something like
msglines = split(item.body,vbcrlf)
for each msgline in msglines
strings = split(msgline," ")
if strings(0) = "TAG" then
do one thing
else if strings(0) = "=" then
do something else
etc, etc
It just isn't working for me so I'm wondering if someone has a better strategy.
TIA
"To view this electronic transmittal and its electronic documents, click the link below.
--
--
-------------------------------------------------------------
EVERYTHING below is a text representation of the link supplied above.
-------------------------------------------------------------
XXX Job Number: E0886 Client Job Number: C71024
C71024 SHU PROJECT EXECUTE
INQUIRY REQ TO PROCUREMENT PIMS REF #: 619 was Issued on 07/17/14 From Job Number: E0886
REQUISITION NBR: I0009 REV:
GLOBAL TRANS. #: 619
--------------------------------------------------------------------------------------------------------------------------
Transmittal Description:
RELIEF VALVES - I0009
--------------------------------------------------------------------------------------------------------------------------
Transmittal Caption:
The listed Inquiry Requisition is hereby transmitted to Purchasing. Please issue
an Inquiry to the listed vendors.
--------------------------------------------------------------------------------------------------------------------------
Remarks:
=============================================================
TAG TAG TAG TAG TAG TAG
--------------------------------------------------------------------------------------------------------------------------
RV-99200
RV-99203
RV-99204
RV-99205
RV-99206
=============================================================
D I S T R I B U T I O N 4.3*
XXX XXXXX
-------------------------------------------------- --------------------------------------------------