Outlook 2003 Calendar to E-mail using Macro

Posted on 2009-04-30
Medium Priority
Last Modified: 2012-06-21
Is there a way to write a macro in outlook that's like a rule that will automatically send an e-mail when a meeting is 24 hours away? For instance, I have a meeting on my calendar and I need to be notified 24 hours before hand, but i'm unable to check my calendar. I'd like an e-mail forwared from my computer(which is left on with outlook running) that says something like , "you have "meeting name" in 24 hours."
Question by:Darkejo1
  • 2
LVL 76

Expert Comment

by:David Lee
ID: 24281052
Hi, Darkejo1.

Yes, that's possible.  I can do it in a couple of ways.  The simplest way will require you to set a reminder 24 hours out.  Will that work?  If not, then I can use a timer to check once an hour, it just means more and therefore the possibility of more problems.

Author Comment

ID: 24281479
Sure, thatll work. Anyway that's easier for you! If possible. Can you explain it at all? I'm kind of interested in learning it a little.
LVL 76

Accepted Solution

David Lee earned 2000 total points
ID: 24281787
Here's the code for doing this.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of
5.  Outlook's VB Editor window
6.  Edit the code as needed.  I included comment lines wherever something needs to or can change
7.  Click the diskette icon on the toolbar to save the changes
8.  Close the VB Editor
9.  Click Tools > Macro > Security
10. Set the Security Level to Medium
11. Close Outlook
12. Start Outlook
13. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Because this code sends a message it is going to trigger Outlook's built-in security.  The result is a popup dialog-box warning that an application is sending a message and asking for your permission to allow it to continue.  Outlook security cannot be disabled, but there are ways to work around it.  Here are the options.

1.  Sign the code.  Here's a link to instructions on doing that: http://msdn.microsoft.com/en-us/library/aa155754(office.10).aspx
2.  Use ClickYes (http://www.contextmagic.com/express-clickyes/), a small utility that'll click the Yes button for you.  It creates a security hole though, since a virus could start sending messages and ClickYes would click the Yes button for it too.  
3.  Use Redemption (http://www.dimastr.com), a COM library that enables code to safely bypass Outlook security.

This works by watching for an appointment's reminder.  When the code sees a reminder it checks to see if the source item is an appointment.  If it is, then it sends a message to you.
Dim WithEvents olkReminders As Outlook.Reminders
Private Sub Application_Quit()
    Set olkReminders = Nothing
End Sub
Private Sub Application_Startup()
    Set olkReminders = Outlook.Application.Reminders
End Sub
Private Sub olkReminders_ReminderFire(ByVal ReminderObject As Reminder)
    Dim olkAppt As Outlook.AppointmentItem, olkMsg As Outlook.MailItem
    If ReminderObject.Item.Class = olAppointment Then
        Set olkAppt = ReminderObject.Item
        Set olkMsg = Outlook.Application.CreateItem(olMailItem)
        With olkMsg
            'Change the address on the next line'
            .Recipients.Add "address@domain.com"
            .Subject = "Appointment Reminder"
            .HTMLBody = "Appointment: " & olkAppt.Subject & "<br>" _
                & "Start: " & olkAppt.Start & "<br>" _
                & "End: " & olkAppt.End & "<br>" _
                & "Location: " & olkAppt.Location
        End With
    End If
    Set olkAppt = Nothing
    Set olkMsg = Nothing
End Sub

Open in new window


Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question