|
-
May 22nd, 2012, 04:56 PM
#1
Thread Starter
New Member
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
-
May 23rd, 2012, 04:28 AM
#2
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|