I have a working code which is extracting information from subject of initial email.
Sub InitialNotif()
Dim origEmail As MailItem
Dim replyEmail As MailItem
Dim INC1 As String 'For Serial Number
Dim INo As Integer 'For Serial Number
Dim LOC1 As String 'For Location
Dim LoC As Integer 'For Location
Dim SUMM As String 'For Summary
Dim Sum As Integer 'For Summary
Set origEmail = Application.ActiveWindow.Selection.item(1)
Set replyEmail = Application.CreateItemFromTemplate("H:\Documents\Test P1-.oft")
replyEmail.CC = ""
replyEmail.HtmlBody = replyEmail.HtmlBody & origEmail.Reply.HtmlBody
INC1 = origEmail.Subject
INo = InStr(1, INC1, "SR2")
LOC1 = origEmail.Subject
LoC= InStr(1, LOC1, "|") + 10
SUMM= origEmail.Subject
Sum= InStr(1, SUMM, "Summary") + 30
replyEmail.Subject = " <P1> - " & INC1
replyEmail.HtmlBody = Replace(replyEmail.HtmlBody, "INC1", INC1)
replyEmail.Display
End Sub
Now I would like to fetch information from body of the email. Below is the format of body of the email.
Serial Number: SR23443354
Location: Canada
Summary: Replacement request
I need above information to be replaced with my .otf
Template. So when I run the script it should auto populate or replace required field.
Template Body:
Serial Number: INC1
Location: LOC
Summary: SUMM
When I tried replacing origEmail.Subject
with origEmail.body
its giving me entire email in scattered format.
Change
ActiveWindow
WithActiveExplorer
MSDN Split Function
MSDN Replace Function
MSDN InStr Function