Outlook回复或回复电子邮件

时间:2015-08-04 19:27:10

标签: vba email outlook outlook-vba

Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
objMail.To = "example@email.com"
objMail.cc = "example2@email.com"
objMail.Subject = "Mail test"
objMail.HTMLBody = "This is my message"
unload me
objMail.Display
Set objMail = Nothing
Set objOutlook = Nothing

我正在尝试添加其他功能,以帮助回复所选的电子邮件,但无法弄清楚如何将其与Item As Outlook.MailItem混合使用 我知道回复电子邮件需要这样做。

所以我想知道如何添加,以便我可以选择一个电子邮件,执行宏,它会将收件人电子邮件输入objMail.To和收件人的正文objMail.HTMLBody

1 个答案:

答案 0 :(得分:3)

要简单地ReplyReplyAll选择的消息,请尝试以下操作。

Option Explicit
Sub ReplyMSG()
    Dim olItem As Outlook.MailItem
    Dim olReply As MailItem ' Reply
    Dim olRecip As Recipient ' Add Recipient

    For Each olItem In Application.ActiveExplorer.Selection
    Set olReply = olItem.ReplyAll
    Set olRecip = olReply.Recipients.Add("Email Address Here") ' Recipient Address
        olRecip.Type = olCC
            olReply.HTMLBody = "Hello, Thank you. " & vbCrLf & olReply.HTMLBody
        olReply.Display

        'olReply.Send
    Next olItem
End Sub

要隐藏收件人,请使用 BCC 实施例

<强> olRecip.Type = olBcc

要添加多个收件人,只需添加

Set olRecip = olReply.Recipients.Add("Email Here")
Set olRecip = olReply.Recipients.Add("Email Here")
Set olRecip = olReply.Recipients.Add("Email Here")

没有收件人,请尝试以下操作。

Option Explicit
Sub ReplyMSG()
    Dim olItem As Outlook.MailItem
    Dim olReply As MailItem ' Reply

    For Each olItem In Application.ActiveExplorer.Selection
    Set olReply = olItem.ReplyAll
            olReply.HTMLBody = "Hello, Thank you. " & vbCrLf & olReply.HTMLBody
        olReply.Display

        'olReply.Send
    Next olItem
End Sub