0

我有这个代码到一个 vba Outlook 宏来回复所有。

Sub my_test()

Dim objItem As Object

Dim mail As MailItem
Dim replyall As MailItem

Dim templateItem As MailItem

For Each objItem In ActiveExplorer.Selection

    If objItem.Class = olMail Then
    
        Set mail = objItem
        Set replyall = mail.replyall
                
        Set templateItem = CreateItemFromTemplate("C:\template.oft")
        
        With replyall
            .HTMLBody = templateItem.HTMLBody & .HTMLBody
            .Display
        End With
        
    End If
    
Next

End Sub

我正在尝试添加一个功能,以便当原始电子邮件带有附件(docx,pdf)时,当我使用此宏回复所有内容时,它也将使用原始附件并将其作为附件放置在回复所有电子邮件中。我怎样才能做到这一点?

4

1 回答 1

1

转发,然后.To用ReplyAll 中出现的内容填充。

Option Explicit

Sub my_test()

Dim objItem As Object

Dim mail As MailItem
Dim forwardMail As MailItem

Dim templateItem As MailItem

For Each objItem In ActiveExplorer.Selection

    If objItem.Class = olMail Then
    
        Set mail = objItem
        Set forwardMail = mail.Forward
        
        Set templateItem = CreateItemFromTemplate("C:\template.oft")
        
        With forwardMail
            .HTMLBody = templateItem.HTMLBody & .HTMLBody
            .To = mail.replyall.To
            .Display
        End With
        
    End If
    
Next

End Sub
于 2021-02-11T13:19:18.610 回答