How to reply to all contacts using original attachment

200 views Asked by At

I have a vba code script which I use to reply all, and send the response to all contacts which come in the original email.

 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

I know that in the original email there might be some attachments (pdf, docx).

How can I add changes/something into this code (keeping this code) so when I use this macro the new email reply response will also get the attachment automatically as attachment? And also replying to everyone.

1

There are 1 answers

1
Morten On

You should read up on the MailItem.Attachments property, e.g. here: https://learn.microsoft.com/en-us/office/vba/api/outlook.mailitem.attachments.

With that, you can grab the existing attachments to an email and attach them to a new one, add/remove etc.