Outlook send email macro with attachments when reminder fires
Using information available via a Google search I have put together an Outlook macro to send an email to a list of recipients when a Calendar reminder fires. The code below works perfectly as long as I don't try to include any attachments that may be present in the Appointment body/details section. I want the reminder email that this macro generates to also include attachments if they are present in the appointment item. Can anyone tell me what code I need to add to make this happen? I have worked/experimented on this issue for many days with no success. I have finally decided to ask the experts. (Note that the source object is an AppointmentItem). Thanks!
Code:
Private Sub Application_Reminder(ByVal EventItem As Object)
Dim MailMsg As MailItem
Set MailMsg = Application.CreateItem(olMailItem)
If EventItem.MessageClass = "IPM.Appointment" Then
Call SendApptMail(MailMsg, EventItem)
End If
Set MailMsg = Nothing
End Sub
Sub SendApptMail(Mail_Item As Object, Appt_Item As Object)
Mail_Item.To = Appt_Item.Location
Mail_Item.Subject = Appt_Item.Subject
Mail_Item.Attachments = Appt_Item.Attachments 'this line throws an error - Help!
Mail_Item.HTMLBody = Appt_Item.Body ‘html formatting omitted for brevity
Mail_Item.Send
End Sub
Re: Outlook send email macro with attachments when reminder fires
you may have to add attachment items and you may have to do it for each attachment in the appt item
vb Code:
for each attch in Appt_Item.Attachments
Mail_Item.Attachments.add attch
next
as i don't use outlook this is just a guess, you will have to test