添加附件到现有电子邮件

时间:2016-09-13 06:26:12

标签: vba outlook outlook-vba

下面的代码添加了一个附件,但它会创建一个新的电子邮件。

Sub BA7()
    Dim myItem As Outlook.MailItem
    Dim myAttachments As Outlook.Attachments
    Set myItem = Application.CreateItem(olMailItem)
    Set myAttachments = myItem.Attachments
    myAttachments.Add "J:\BUILDING\Email attachments\BA7word.docx", _
    olByValue, 1, "BA7"
End Sub

有没有办法在当前打开的电子邮件中添加附件?

1 个答案:

答案 0 :(得分:1)

替换

Set myItem = Application.CreateItem(olMailItem)

Set myItem = Application.ActiveInspector.CurrentItem

如果在检查器中打开该项目,或者如果在资源管理器消息列表中选择了该项目,则使用以下项目:

Set myItem = Application.ActiveExplorer.Selection(1)