H
hstockbridge5
Hi,
I can successfully parse elements from one email message using Sue
Mosher's code (GetCurrentItem) and (ParseTextLinePair.) However, I
want to process multiple messages. How would I do that? Would I alter
the GetCurrentItem procedure, the procedure below, or both?
Sub MessageParse()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fso, f, ts
Dim objItem As Object
Dim intLocAddress As Integer
Dim intLocCRLF As Integer
Dim strTitle As String
Dim strFirstName As String
Dim strLastName As String
Dim strEmail As String
Dim strProf As String
Dim strMedSpec As String
Dim strHosp As String
Dim strCity As String
Dim strState As String
Dim strZip As String
Dim strCountry As String
Dim strRegVia As String
Dim strPromo As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("c:\Messages.txt")
Set ts = f.OpenAsTextStream(ForAppending, TristateUseDefault)
Set objItem = GetCurrentItem()
If objItem.Class = olMail Then
' Parse items in email body
strTitle = ParseTextLinePair(objItem.Body, "Title:")
strFirstName = ParseTextLinePair(objItem.Body, "First Name:")
strLastName = ParseTextLinePair(objItem.Body, "Last Name:")
strEmail = ParseTextLinePair(objItem.Body, "Email Address:")
strProf = ParseTextLinePair(objItem.Body, "Profession:")
strMedSpec = ParseTextLinePair(objItem.Body, "Medical
Specialty:")
strHosp = ParseTextLinePair(objItem.Body, "Hospital:")
strCity = ParseTextLinePair(objItem.Body, "City:")
strState = ParseTextLinePair(objItem.Body, "State/Province:")
strZip = ParseTextLinePair(objItem.Body, "Postal Code:")
strCountry = ParseTextLinePair(objItem.Body, "Country:")
strRegVia = ParseTextLinePair(objItem.Body, "Registered via:")
strPromo = ParseTextLinePair(objItem.Body, "Promotion Code:")
End If
ts.Write strLastName
ts.WriteLine
ts.Close
Set objItem = Nothing
End Sub
I can successfully parse elements from one email message using Sue
Mosher's code (GetCurrentItem) and (ParseTextLinePair.) However, I
want to process multiple messages. How would I do that? Would I alter
the GetCurrentItem procedure, the procedure below, or both?
Sub MessageParse()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fso, f, ts
Dim objItem As Object
Dim intLocAddress As Integer
Dim intLocCRLF As Integer
Dim strTitle As String
Dim strFirstName As String
Dim strLastName As String
Dim strEmail As String
Dim strProf As String
Dim strMedSpec As String
Dim strHosp As String
Dim strCity As String
Dim strState As String
Dim strZip As String
Dim strCountry As String
Dim strRegVia As String
Dim strPromo As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("c:\Messages.txt")
Set ts = f.OpenAsTextStream(ForAppending, TristateUseDefault)
Set objItem = GetCurrentItem()
If objItem.Class = olMail Then
' Parse items in email body
strTitle = ParseTextLinePair(objItem.Body, "Title:")
strFirstName = ParseTextLinePair(objItem.Body, "First Name:")
strLastName = ParseTextLinePair(objItem.Body, "Last Name:")
strEmail = ParseTextLinePair(objItem.Body, "Email Address:")
strProf = ParseTextLinePair(objItem.Body, "Profession:")
strMedSpec = ParseTextLinePair(objItem.Body, "Medical
Specialty:")
strHosp = ParseTextLinePair(objItem.Body, "Hospital:")
strCity = ParseTextLinePair(objItem.Body, "City:")
strState = ParseTextLinePair(objItem.Body, "State/Province:")
strZip = ParseTextLinePair(objItem.Body, "Postal Code:")
strCountry = ParseTextLinePair(objItem.Body, "Country:")
strRegVia = ParseTextLinePair(objItem.Body, "Registered via:")
strPromo = ParseTextLinePair(objItem.Body, "Promotion Code:")
End If
ts.Write strLastName
ts.WriteLine
ts.Close
Set objItem = Nothing
End Sub