
Originally Posted by
hrq
Hi All
I would like to attach attachments from an existing email when a reply all is executed without the need to save the attachment into a specific folder. I tried using the following code but it populates an error run time 438. Is there a way to fix this?
The macro is executed from excel.
Set myAttachment = Item.Attachments
Set OutMail = Item.ReplyAll
If myAttachment.Count >= 1 Then
With OutMail
.HTMLBody = "Hi Siew Ping, <p> $" & strPayment & " received On the " & strPaymentdate & " .<p> Thanks & Regards," & .HTMLBody
.Attachments.Add myAttachment
.Display
'.Send
End With
Else
With OutMail
.HTMLBody = "Hi Siew Ping, <p> $" & strPayment & " received On the " & strPaymentdate & " .<p> Thanks & Regards," & .HTMLBody
.Display
'.Send
End With
End If
To attach attachments from an existing email when a reply all is executed using VBA, you can use the Attachments property of the MailItem object, which represents an email message.
Here is an example of how you can do this:
Sub ReplyAllWithAttachments()
Dim objOutlook As Outlook.Application
Set objOutlook = New Outlook.Application
' Get the currently selected email in Outlook
Dim objMail As Outlook.MailItem
Set objMail = objOutlook.ActiveExplorer.Selection.Item(1)
' Create a new email for the reply
Dim objReply As Outlook.MailItem
Set objReply = objMail.ReplyAll
' Loop through the attachments in the original email
Dim objAttachment As Outlook.Attachment
For Each objAttachment In objMail.Attachments
' Attach each attachment to the reply email
objReply.Attachments.Add objAttachment
Next objAttachment
' Show the reply email so the user can edit it and send it
objReply.Display
End Sub