转发Outlook电子邮件

时间:2018-01-09 04:21:08

标签: vba email outlook outlook-vba

我正在运行这些行以在Outlook中创建新电子邮件。他们运作良好。

现在,当我转发电子邮件(而不是创建新电子邮件)时,我想让它们正常工作,并在转发时包含原始电子邮件。

我该怎么做?似乎只有Application.CreateItem方法(Outlook)而没有ForwardItem?谢谢。

Sub CreateMsg0()
Dim objMsg As MailItem

Set objMsg = Application.CreateItem(olMailItem)

 With objMsg
  .To = "Alias@domain.com; Alias111@domain.com; Alias222@domain.com"
  .CC = "Alias2@domain.com"
  .Subject = "This is the subject"

  .HTMLBody = "<p style='color:rgb(0,51,102);font-family:calibri;font-size:18'>" & ep _
              & "Hello," & "<br>" & "<br>" & "<br>" & ep _
              & "Email body writing line number 1." & "<br>" & ep _
              & "Email body writing line number 2." & "<br>" & ep _
              & "</p>" & ep _
              & "<br>" & "<br>" & "<br>" & ep _
              & "<p style='color:rgb(0,51,102);font-family:calibri;font-size:15'>" & ep _
              & "Signature line 1." & "<br>" & ep _
              & "Tel./fax." & "<br>" & ep _
              & "</p>"


  .Display

End With

Set objMsg = Nothing
End Sub

1 个答案:

答案 0 :(得分:1)

什么是 ep _ ?任何方式应该是示例

Option Explicit
Sub CreateMsg0()
    Dim objMsg As mailitem
    Dim Item As Outlook.mailitem

    Set Item = Application.ActiveExplorer.Selection.Item(1)

    Set objMsg = Item.Forward

    With objMsg
        .To = "Alias@domain.com; Alias111@domain.com; Alias222@domain.com"
        .CC = "Alias2@domain.com"
        .Subject = Item.Subject

        .HTMLBody = "<p style='color:rgb(0,51,102);font-family:calibri;font-size:18'>" _
                & "Hello," & "<br>" & "<br>" & "<br>" _
                & "Email body writing line number 1." & "<br>" _
                & "Email body writing line number 2." & "<br>" _
                & "</p>" _
                & "<br>" & "<br>" & "<br>" _
                & "<p style='color:rgb(0,51,102);font-family:calibri;font-size:15'>" _
                & "Signature line 1." & "<br>" _
                & "Tel./fax." & "<br>" _
                & "</p>" & "<BR>" & Item.HTMLBody

        .Display
    End With

    Set objMsg = Nothing
End Sub

对于主题= .Subject = Item.Subject &amp;正文 & Item.HTMLBody

如果您需要原始电子邮件中的收件人,则示例为

With objMsg
    .To = Item.To
    .CC = Item.CC
    .Subject = Item.Subject

MSDN MailItem.Forward Method (Outlook)