Results 1 to 2 of 2

Thread: Sending e-mails through separate reminders

  1. #1
    VBAX Newbie
    Aug 2017

    Sending e-mails through separate reminders

    Totally new to using VBA but through searching through various search engines (mainly Google) I managed to come up with code to send an automated e-mail through a pop-up reminder (and subsequently dismiss it). What I'm hoping to be able to do is send different automated e-mails through different reminders but don't quite know how to set it up (where to put the code to send the different e-mail). My current code looks like so:

    Private Sub Application_Reminder(ByVal Item As Object)
        Dim wd As Object, editor As Object
        Dim doc As Object
        Dim oMail As MailItem
        Dim outapp As Object
        Dim outmsg As Object
        Set olRemind = Outlook.Reminders
        Set outapp = CreateObject("outlook.application")
        Set outmsg = outapp.CreateItem(0)
        If Item.MessageClass <> "IPM.Appointment" Then Exit Sub
        If Item.Categories <> "Send Schedule Recurring Email" Then Exit Sub
        Set wd = CreateObject("Word.Application")
        Set doc = wd.Documents.Open(FileName:="C:\MyFile.docx")
        Set wd = Nothing
        Set oMail = Application.CreateItem(olMailItem)
        With oMail
             .BodyFormat = olFormatRichText
             Set editor = .GetInspector.WordEditor
            .To = Item.Location
            .Subject = Item.Subject
         End With
    End Sub
    Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)
        For Each objRem In olRemind
                If objRem.Caption = Item.Subject Then
                    If objRem.IsVisible Then
                        Cancel = True
                    End If
                    Exit For
                End If
            Next objRem
    End Sub
    Any help is appreciated!


  2. #2
    VBAX Mentor skatonni's Avatar
    Jun 2006
    On possibility would be to differentiate by Subject.

    If Item.Categories <> "Send Schedule Recurring Email" Then Exit Sub
        Select Case Item.Subject
        Case "Reminder One"
            Debug.Print "Reminder one"
            'Set wd = CreateObject("Word.Application")
            'Set doc = wd.Documents.Open(filename:="C:\MyFile.docx")
            'Set wd = Nothing
        Case "Reminder Two"
            Debug.Print "Reminder two"
            'Set wd = CreateObject("Word.Application")
            'Set doc = wd.Documents.Open(filename:="C:\MySecondFile.docx")
           ' doc.Close
            'Set wd = Nothing
        End Select
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code.

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts