Link to home
Start Free TrialLog in
Avatar of DavidRGarner

asked on

Outlook Visual Basic - Reminder Event

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!

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  'other html formatting omitted for brevity
End Sub

Open in new window

Avatar of Pr1z
Flag of United Kingdom of Great Britain and Northern Ireland image

Have you tried to add each attachment individually rather than as a collection?? something like:
for each oAttachment in Appt_Items.Attachments
     Mail_Item.Attachments.add oAttachment

Open in new window

Hope this helps

Avatar of DavidRGarner

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial