Updated Outlook Macro for Creating Appointments


Last year I created a simple macro for Microsoft Outlook 2007 that automatically created an appointment from an email, adding the recipients to the appointment invite.  Apparently there has been quite a bit of interest in this, most recently someone asked if it could be modified so that it would work with the previewed email in addition to an opened email.  Well I looked at the code again and found that it was pretty easy to do: 


If the active inspector is null, then no item is opened.  I then check to see if the preview pane is visible and if it is, I get the first selected item (because only the first item is previewed). 


I have attached the updated source code for your use and productivity.  Thanks for all of your suggestions!


Dim app As New Outlook.Application
Dim item As Object

If app.ActiveInspector Is Nothing Then
If app.ActiveExplorer.IsPaneVisible(olPreview) Then
Set item = app.ActiveExplorer.Selection.item(1)
End If
Else
Set item = app.ActiveInspector.CurrentItem
End If

If item Is Nothing Then Exit Sub

If item.Class <> olMail Then Exit Sub
….


NewMeetingRequestFromEmail.bas

Comments (14)

  1. James says:

    Hey there, I was the bloke interested in having it done from the preview pane. And woaw, that was done quickly. Indeed, it works like a charm.

    Thanks a lot! :D

  2. Derek Blair says:

    Here is something we are working on. We are using your code (thank you) but want a rule to create a calendar event. We have found how to do this but your code and the above code need to have a window open or have a preview. What if you don’t need or want to see the email.

    What happens is that a helpline sends an email to me saying I have a call and need to contact the client. I then have to create a calendar event for this. It would be nice if a rule could grab the info out of the email and create the calendar event for me. Saves me some time.

    Can this be done or does a active window need to be open?

  3. Derek Blair says:

    A programmer friend helped me out. I am almost there.

  4. Vele says:

    in office2007 it is enaught to drag & drop mail to Calendar or task. Drag with right button for more options

  5. Arnoud Bergman says:

    Tired of having to add the e-mail addresses to a meeting by drag & dropping the e-mail on the Calender, I very much enjoyed your article solving this problem. Implementing the macro I unfortunately found that Outlook 2003 has a new security feature in showing a display with:

    "a program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this?"

    and allowing a time window of 1,2 or 5 minutes. For the record: a selfcert certificate does not help in this case.

    Luckily I found a simple solution to this browsing the internet by letting the macro not use a new instance of the outlook application object (thus triggering the security response), but using the outlook application object itself with results in a few changes in the VBA code which I hope you will adopt (after testing of course):

    Replace

       …

       Dim app as new outlook.application

       …

    By

       …        

       Dim app As Outlook.Application

       Set app = Application

       …

    Cheers,

    Arnoud Bergman

    afbergman(at)zonnet.nl

  6. evert says:

    hi there,

    i’m looking for a different macro but i hope you could help me.

    i’m trying to get my calendar better organized with all the meetings that i have. often i don’t have time between meetings to either prepare for or even get from one meeting to another.

    i would like to have a macro that automatically adds 15 minutes to each meeting at its beginnnig and/or end.

    could anyone help me?

    thanks,

    evert

  7. I think you may be able to help me with something.  I would like a Gantt type display of an Outlook calendar.  I attempted to use Microsoft Project ’07, but was unimpressed by its lack of connectivity and its oulandishly large tables.  Really if there is a way to print weekly calendars contiguously or monthly calendars with more than a few events showing, that would be great too.  If you have any suggestions or ideas, let me know at Michael "|)ot" Crone1 "@t" us "d0TT" army "d0t" mil

    Any assisstance is appreciated, thanks!

  8. Mark says:

    This used to work on my computer, but it seems to have problems after an update that was pushed on me.

    I am now getting a Run-time error 287 (Application-defined or object-defined error)

    It is happening at the "meetingRequest.Body = email.Body" line in the main subroutine.

    Any suggestions or thoughts as to why this is occurring?  

    Much appreciated.

    Mark

  9. Vince says:

    Is there a way to create a macro and attach it to an outgoing message so that when the message arrives in the recipients Inbox an appointment is automatically created? What we are attempting to accomplish is to give every receipient of an upgrade email message a reminder to reboot their machine 3 days after receiving the email. We think that a macro attached to an outgoing mail message which runs as soon as the message is received may accomplish this. Thank you!

  10. Lachlan says:

    Hi there…

    At work we use our calendar as a timesheet and recently have begun looking into macros to speed the process…

    How would a macro that takes the start time and end time, and put it into the body as total time work?

    If you could help with this, that would be great!

    Thanks

    Lachlan

  11. Hello,

    This may not be the right place but I am getting desperate.  I have a VBA script to create a new outlook appointment fom an Access form but I cannot figure out how to update an existing appointment through the script.  I have been trying to us the GlobalAddressID and the EntryID properties as a way of identifying the item but I cannot get anything to work.

    Can you please help?

  12. This script is great! Did the trick for me…

    … Until I found out this functionality is in the Box. See: http://www.gilsmethod.com/create_calendar_entry_using_emails

  13. C.B. McCoy says:

    Has anyone gotten this macro to work under Windows 7? It works fine under Windows XP but won't work in Windows  7.