Outlook宏可复制主题行并粘贴到正文中

时间:2018-10-24 23:02:42

标签: vba outlook outlook-vba

任何人都可以通过宏帮助我自动复制主题行并粘贴到邮件正文中。我已经有一个宏可以用“亲爱的(收件人)电子邮件”填充正文,但是我还需要在电子邮件中添加主题行。

Sub Test()
  Dim mItem As MailItem
  Dim mItem1 As MailItem
  Dim ToValue
  Set mItem = ActiveInspector.CurrentItem
  Set mItem1 = ActiveInspector.CurrentItem

  ToValue = Trim(mItem.To)
  'Replace all possible delimiters with a comma
  ToValue = Replace(ToValue, ";", ",")
  ToValue = Replace(ToValue, " ", ",")
  'Remove double delimiters
  Do While InStr(ToValue, ",,") > 0
    ToValue = Replace(ToValue, ",,", ",")
  Loop
  'Split into words
  ToValue = Split(ToValue, ",")
  'Use the first name only
  'Note:
  '  For the 2nd name use ToValue(1) instead (enable this line):
  'If UBound(ToValue) > 0 Then ToValue(0) = ToValue(1)
  mItem.HTMLBody = Replace(mItem.HTMLBody, "Customer", ToValue(0), Compare:=vbTextCompare)
  mItem1.HTMLBody = Replace(mItem1.HTMLBody, "Subject", subject, Compare:=vbTextCompare)
End Sub

0 个答案:

没有答案