使用VBA对收件箱中的选定电子邮件进行回复并添加密件抄送收件人

时间:2019-02-03 14:47:03

标签: vba outlook outlook-vba outlook-2016

我想在我的Outlook收件箱中写一封对选定电子邮件(或电子邮件地址)的答复,而不引用发件人的邮件,每封邮件都直接发送给发件人。

尝试以下代码,但仅适用于一封选定的电子邮件。当我在宏上运行它时,它将自动发送空白消息以及发件人带引号的消息。

Sub test()

Dim m As MailItem 'object/mail item iterator
Dim recip As Recipient 'object to represent recipient(s)
Dim reply As MailItem 'object which will represent the reply email

'Loop over each SELECTED item:
For Each m In Application.ActiveExplorer.Selection
If m.Class = olMail Then
Set reply = m.reply

'Adds a "direct replies to" address:
reply.ReplyRecipients.Add "XXXX@email.com"

'Adds BCC recipient to the reply:
Set recip = reply.Recipients.Add("someone_else@email.com")
recip.Type = olBCC '3

reply.Save 'saves a draft copy to your SENT folder
reply.Send

End If
Next

End Sub

1 个答案:

答案 0 :(得分:0)

使用.HTMLBody Property (Outlook).Body Property

.Body返回或设置一个表示电子邮件的明文正文的字符串。

.HTMLBody返回或设置一个表示指定电子邮件的HTML正文的字符串。

示例

'Loop over each SELECTED item:
For Each m In Application.ActiveExplorer.selection
    If m.Class = olMail Then
        Set reply = m.reply

        'Adds a "direct replies to" address:
        reply.ReplyRecipients.Add "XXXX@email.com"

        'Adds BCC recipient to the reply:
        Set recip = reply.Recipients.Add("someone_else@email.com")
        recip.Type = olBCC '3

        reply.Save
        reply.Display ' or .send
        reply.HTMLBody = "Hello " & reply.HTMLBody
    End If
Next

选择多个电子邮件以在正文中重播相同的信息。

相关问题