我有一个工作代码,它正在从初始电子邮件的主题中提取信息。
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
现在我想从电子邮件正文中获取信息。以下是电子邮件正文的格式。
Serial Number: SR23443354
Location: Canada
Summary: Replacement request
我需要将以上信息替换为我的.otf
模板。因此,当我运行脚本时,它应该自动填充或替换必填字段。
模板正文:
Serial Number: INC1
Location: LOC
Summary: SUMM
当我尝试替换origEmail.Subject
它时,origEmail.body
它会以分散的格式给我整封电子邮件。