Results 1 to 2 of 2

Thread: Outlook send email macro with attachments when reminder fires

  1. #1
    New Member
    Join Date
    May 12
    Posts
    1

    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

  2. #2
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,524

    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:
    1. for each attch in Appt_Item.Attachments  
    2.   Mail_Item.Attachments.add attch
    3. 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
  •