-1

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.

H.N.
  • 1,207
  • 2
  • 12
  • 28

1 Answers1

0

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.

Morten
  • 148
  • 6
  • Thanks for your help. Don´t really know why you deleted the code you pasted here but ok. Anyway I figure it out and was able to achieve what I wanted. – H.N. Feb 15 '21 at 17:01