Creating an Outlook Appointment based on an Email Message


I’ve always wanted to do this:  I get an email message and I want to create an appointment from the the message.  It’s a simple task and I found that this was one of the goals of Chandler in the book that I’m reading right now, Dreaming in Code by Scott Rosenberg.  Incidentally, I just met Scott at Scoble’s Geek/Blogger dinner in San Francisco last week.  From the book, I learned that the software architecture that the Chandler team was using to accomplish this task was very complex.  I looked into the Outlook 2007 UI I did not find this feature.  Last week I visited a customer and the engineering manager there asked how to do this.  The beauty of Outlook is that it is programmable!  In about an hour, I was able to write a short VBA Macro that does the following:



  1. If the current item is an email, create a new appointment item

  2. Copy the categories, body, and subject

  3. Copy the attachments

  4. Add the sender as a meeting participant

  5. Add each email recipient as a meeting participant

  6.      Each To: participant will be a required

  7.      Each CC: or BCC: participant will be optional

I then added the macro to my quick launch bar for an Outlook message and it worked!




I have attached the macro for all of you to try out.


Enjoy,


Michael


5/24/2007: Updated macro to fix bug with copying attachments.

NewMeetingRequestFromEmail.bas

Comments (83)

  1. Synergist says:

    When I posted the simple macro to create an appointment from an email message , I got a message from

  2. djwriter says:

    Silly question, but I’m new to macros.  How do I get from the script attachment to the quick launch bar?  Do I need to copy and paste the script to a txt file and drag that to the bar?  Or something else?  Thanks for any help you can offer.

  3. Synergist says:

    Silly me. When I posted the macros to create Outlook appointments based on email messages and to schedule

  4. Synergist says:

    djwriter,

    Here’s an explanation of how to add a macro to Outlook:

    http://blogs.msdn.com/synergist/archive/2007/05/23/adding-a-vba-macro-to-outlook.aspx

    Michael

  5. Tim Toennies says:

    This works perfect, great job.

  6. Micha Schmeink says:

    Hello,

    I’m new to macros, and I would lik te know if it is possible te rewrite teh script so that i can make a task of certan e-mails.

    Micha

  7. jones says:

    Hello,

    Can you help me out ?

    I am looking to write a macro that takes

    the information of an outlook meeting and creates a word / mail meeting summery

    (using the information from the meeting document)

    thank you

    Jones

  8. MF says:

    I’m tryng to modify your script to attach an "email" to the appointment, but with out success

    Can you help me?

    Thanks

  9. MF says:

    I’ve just solved my problem

    here is the solution

    Set myAttachments = TaskRequest.Attachments

    myAttachments.Add app.ActiveInspector.CurrentItem,olEmbeddeditem, 1, email.Subject

  10. Marjorie Wilner says:

    Now that i’ve moved from outlook 2003 to 2007, my Getting Things Done add-in no longer works. Does anyone know how to create an Outlook task based on an email, which is one of the main things I relied on the add-in for?

  11. Michael Karafotis says:

    Wonderful Macro!!  Been looking for something like this for a couple years and expected O2007 would have it.  Thanks for making me more efficient and expanding my VBA knowledge to Outlook.

    Great work!

  12. Robert says:

    I get an error when this macro runs.

      Run time error ’91’

      Object bariable or with block variable not set

    the debuger stops at:

      Set item = app.ActiveInspector.CurrentItem

  13. Synergist says:

    Robert,

    1. Are you using Outlook 2007?

    2. What is the active inspector?  Is it the Message inspector?

    Michael

  14. RCS says:

    Not to make this over-simplified, but you can do the same thing by selected a message or several messages, and dragging them onto the "Calendar" item. This works in pretty much every version of Outlook including 2007.

    It won’t make the e-mails as attachments, but it does copy the contents into the meeting notice.

  15. Synergist says:

    The macro does the following in addition to the behavior seen by dragging the message to the calendar:

    Copy the categories

    Copy the attachments

    Add the sender as a meeting participant

    Add each email recipient as a meeting participant

        Each To: participant will be a required

        Each CC: or BCC: participant will be optional

  16. Bala says:

    I think I figured the earlier one out (just shows how much I have been waiting for something like this!). Accomplished it by changing the security settings (Tools->Macro->Secuirty->Programmatic Access).

    However, I have another problem.

    Since I have numerous filters set up, I normally have my Unread Mail window always open (in fact that is my default, not Inbox). I added your macro to the toolbar here, and tried to invoke it once I saw the message I want displayed in the reading pane. I did not click the message to open in a separate window. I get this error message:

    Run-time error ’91’; Object variable or With block variable not set. However, if I have the message open in a separate window, I can invoke the Macro either from the Unread Mail window, or from this separate window without any issues.

    Is there any fix for this?

    thanks!

    rgds,

    bala

  17. Gary says:

    Bala,

    I had the same question and fixed it by adding the

    GetCurrentItem function listed at:

    http://www.outlookcode.com/codedetail.aspx?id=50

    and then replacing the Set item line with:

       Set item = GetCurrentItem()

    Works now in either the reading pane or when in an e-mail window (depending on which window’s macro button is hit).

  18. Gutharius says:

    Any way to change this macro so it can run as a rule in Outlook 2K7 and have it use the emails .sendon as the start and end time so a reminder is triggered?

  19. Gutharius says:

    OK so I fixed my last question. Here is a hacked version of your code that you can use in a rule as a script. I will be using this for all email that I send to myself so I would get calendar reminders for the quick one liner reminder emails I send to myself.

    Sub NewMeetingRequestFromEmail(item As Outlook.MailItem)

       Dim email As MailItem

       Set email = item

       Dim meetingRequest As AppointmentItem

       Set meetingRequest = Application.CreateItem(olAppointmentItem)

       meetingRequest.Body = email.Body

       meetingRequest.Subject = email.Subject

       meetingRequest.Start = email.SentOn

       meetingRequest.End = email.SentOn

       meetingRequest.ReminderSet = True

       meetingRequest.ReminderMinutesBeforeStart = 1

       meetingRequest.Save

    End Sub

  20. Bala says:

    Gary,

    Thanks for that little piece. It worked exactly as I wanted to! I have it in my Unread Mail and Quick Launch bar, so works everywhere.

    rgds,

    bala

  21. Thijs says:

    Thanks mate,

    I’ve been looking for such a snippet code (only the attachment part). I transformed it to work with my own macro for making tasks.

  22. Aaman says:

    Hi,

    Thanks for this useful technique. One question:

    How do I associate an email with an existing task? I would have expected to be able to drag and drop an email onto a task, but that doesn’t work. Ideally, one should be able to select an email, click a button or a context-menu item, and select a task to associate the email to, in effect, attaching the email to the existing task.

  23. Synergist says:

    Aaman,

    In Outlook 2007, I can do this in two ways:

    Attaching Item:

    1. Open the task for editing

    2. Select the Insert tab

    3. Press the Attach Item button (in the Include group)

    4. Select the item.

    Dragging An Item:

    1. Open the task for editing

    2. Drag the email icon into the body of the task

  24. Nathan says:

    First, thanks, this gets me most of the way to where i need to go.

    I’ve been playing with this macro to try to see if I can get it to read the simple body to pull out names, dates and a subject to be used in the appointment but I’m not sure if the methods I’m using are correct.

    I’ve been trying to use the .IndexOf and Substring functions to cut up the string and define variables but I seem to have a mismatch with my variables.

    Here’s the mess I’ve made, any help?

    Dim X As Integer

    Dim Y As Integer

    Dim name, reason, bodystring As String

    bodystring = meetingRequest.Body

    X = bodystring.IndexOf("#")

    X = X + 2

    Y = bodystring.IndexOf("$")

    Y = Y – 2

    name = bodystring.Substring(X, Y)

    X = ""

    X = Y + 4

    Y = bodystring.IndexOf("!") – 2

    meetingRequest.Start = bodystring.Substring(X, Y)

    X = ""

    X = Y + 4

    Y = bodystring.IndexOf("?") – 2

    meetingRequest.End = bodystring.Substring(X, Y)

    X = ""

    X = Y + 4

    Y = bodystring.IndexOf("~") – 2

    reason = bodystring.Substring(X, Y)

    With meetingRequest

           .Subject = "" & name & " – " & reason & ""

           .ReminderSet = False

           .AllDayEvent = True

    EndWith

    The #, $, !, ? and ~ are just to help me mark and divide up the string.

    Been a while since I’ve tried to do this kind of stuff and I’m not sure if IndexOf and Substring even work with Outlook 2003.

    Anyone have any ideas?

  25. Hugo says:

    Need to create buttons for:

    Permanently delete (without warning pop-up)

    Move to (specific folders) with one click action

    Macros? I don’t know code but I may be able to figure out how to tweak one.

    Thanks!!!

  26. Gilliankey says:

    Michael, I don’t know how to "do" macros. but if you answer me I’ll find someone who can help me. What I’m trying to do is to have outlook automatically make an appointment if i get a spacific email (these emails can be defined by words in their subject).The date can be found in the body of the email always following a unique name or it can be in the subject. The name of the appointment can be found the same way. the time can be "all day". and the catagory is given to the email through a simple rule I made when i get the email. ok that’s about it. can you help? is this possible?

    Thank you,

    Katie

  27. Snyper912 says:

    Mike,

    I’m looking for the same thing Katie is.  I have a class that uses an online resource, and this site emails me 24 hours prior to a new assignment deadline.  I’m looking for a rule that can auto-add an appointment without my explicit action.

    Can this be done?

    Thanks,

    Mark

  28. This is a bit crude, but it works for a specific layout of email that I get that has the appt, time and location in, I wanted to add the location to the subject line as well.

    Hope it helps

       If LCase(sender.Address) = LCase("mysupplier@theirdomain.com") Then

    ‘      Create meetingRequest

         Dim X As Integer

         Dim Y As Integer

         Dim startDay, startTime, endTime, postcode, bodystring As String

         bodystring = meetingRequest.Body

    ‘ get meeting start day and time (line 7) preceded by "Appt Date:"

         X = InStr(bodystring, "Appt Date:")

         X = X + 11

          startDay = Mid(bodystring, X, 10)

         X = X + 14

          startTime = Mid(bodystring, X, 5)

    ‘ set meeting end time (add 1 hour to the start time and watch out for 09h/19h)

         Y = Mid(startTime, 2, 1)

         If Y < 9 Then

               Y = Y + 1

               endTime = Mid(startTime, 1, 1) & Y & Mid(startTime, 3)

            Else

               Y = Mid(startTime, 1, 2)

               Y = Y + 1

               endTime = Y & Mid(startTime, 3)

         End If

    ‘ get postcode use last bit of 12th line next line is a divider, followed by "Employed:"

    ‘ it can vay from 3 characters to 9 characters, and is always preceded by ", "

         X = InStr(bodystring, "Employed:")

         X = X – 75

           postcode = Mid(bodystring, X, 9)

           Y = InStr(postcode, ",")

           If Y > 0 Then

             postcode = Mid(postcode, Y + 1)

           End If

          postcode = UCase(Trim(postcode))

          meetingRequest.Start = startDay & " " & startTime

          meetingRequest.End = startDay & " " & endTime

          meetingRequest.Subject = postcode & " – " & meetingRequest.Subject

          meetingRequest.ReminderSet = False

          meetingRequest.Categories = "Advent"

       End If

  29. N W Sheff says:

    I have been saving a lot of emails into a folder on AOL.  I was wondering if there was a way to write a macro (or script in aol) that would open the email and paste it to the bottom of a word document.  Any help you can provide?

    Thanks

    N Bill Sheff

  30. N W Sheff says:

    I have been saving a lot of emails into a folder on AOL.  I was wondering if there was a way to write a macro (or script in aol) that would open the email and paste it to the bottom of a word document.  Any help you can provide?

    Thanks

    N Bill Sheff

  31. Help says:

    This keeps making the same appointment for the same mail message for me.  I have Outlook 2003.

  32. Synergist says:

    I wrote this macro for Outlook 2007.  I have not tested it for Outlook 2003.

    Michael

  33. Chris Romp says:

    This is a cool macro, but did you know you can just drag the email to the calendar button, or to a specific date in the calendar in the to-do bar, and it’ll create an appointment for you?

  34. Chris Romp says:

    Oops — just saw your response to a similar comment above.  That’ll teach me. =)

  35. miguel says:

    excelent!! I don’t know why outlook 2007 still does not do this?

  36. James says:

    Pffft, I can’t get it to work, really. Not even a basic calander appointment.

    I just want a mail to be copied into a new calander appointment, not even to have all the dates and stuff set, but just simply that the subject is already prefiled and that it has the original e-mail….

    Copied the scripts above, they didn’t work for me. Tried fixing the code but it doesn’t ever work :S

    Using Outlook 2007

  37. James says:

    Arg, I only know realize this only works when opening the message… *sigh*

    How can I get it to work from the preview pane? The adding of the correspondents is really neat tho 🙂

  38. Synergist says:

    Last year I created a simple macro for Microsoft Outlook 2007 that automatically created an appointment

  39. Mike says:

    Thanks!  This is perfect.  I added a flag on mine to categorize e-mails I’ve made into appointments.

  40. Robert says:

    I made a couple of changes to the macro:

    1) Add the current eMail as an attachment to the appointment rather than copying the body text.

       ‘ Change this to add the eMail as an attachment to the appointment

       ‘meetingRequest.Body = email.Body

       meetingRequest.Body = "As referenced in the attached:" & vbCrLf

       meetingRequest.Attachments.Add email, olEmbeddeditem, 1, email.subject

    2) Allow for the selected eMail to be one that is in the "Sent Items" folder.

       ‘ If the selected eMail is in "Sent Items" then the

       ‘ email.SenderEmailAddress is an empty string

       ‘ So do not attempt to add it to the meetingRequest as it will fail

       If LCase(email.SenderEmailAddress) <> "" Then

        Set recipient = meetingRequest.Recipients.Add(email.SenderEmailAddress)

        recipient.Resolve

       End If

  41. Napoleon says:

    this is cool… but is it possible to save this to a different calendar besides mine. i have another account attached to my email and i want it to save to my second account’s calendar which is also shared so everybody can see

    thanks

  42. Brent says:

    Did anyone ever modify this to let you chose a calendar to save the appointment to a different calendar?  

  43. Mr. Ected says:

    Love the Macro, but when I use it on an email that has html and graphics, it moves over into the appointment as all text. I am using OL Enterprise 2007.

    TIA

  44. Nitzan says:

    I wanted this code so much….

  45. Michael (Also) says:

    I have been looking for something that links emails to appointments, and appointments to tasks.  This macro has gotten me halfway there. Thank you!  Of course, I must ask, is there something that would get me the rest of the way there?

  46. Shawn Michaels says:

    I just wanted some basic meeting creating example from VB. For someone just interested in seeing some peoples scheduling availability here is a macro:

    Public Sub hbk()

       Dim George As String

       Dim Dick As String

       George = "George W. Bush"

       Dick Cheney = "Dick Cheney"

       Set meeting = Application.CreateItem(olMeeting)

       meeting.Display

       meeting.Recipients.Add (George)

       meeting.Recipients.Add (Dick)

       Set objInsp = meeting.GetInspector

       objInsp.SetCurrentFormPage "Scheduling"

    End Sub

  47. charles says:

    Thanks! This is just what I needed. I don’t understand why Microsoft doesn’t include this function by default.

  48. Carolyn says:

    This is all great and new to me. I need some help creating a macro based on an email received.

    On the body of the email, I have the option to accept or decline a project request/order. I would like to create a macro that will allow my outlook to accept each order as it arrives by

    1. automatically selecting accept

    2. log in to the system using the required username and password

    3. complete the acceptance process in the project system

    HELP!!!!!!

  49. Mason says:

    This worked great in Outlook 2003 AFTER I deleted these lines:

       Set recipient = meetingRequest.Recipients.Add(email.SenderEmailAddress)

       recipient.Resolve

    I don’t know why this line flunks in 2003, but I also don’t know why I’d want to be a participant when I’m also the organizer.

    Thanks for your work!

  50. Mason says:

    Worked perfectly in Outlook 2003 after deleting these lines:

       Set recipient = meetingRequest.Recipients.Add(email.SenderEmailAddress)

       recipient.Resolve

    Thanks!

  51. Brian says:

    or you could just drag the email to the outlook icon.  Works perfectly every time.

    http://blogs.bnet.com/businesstips/?p=1207

  52. Queny says:

    It is amazing how you can find almost anything you are looking for these days on the web.

    Thanks Mike for putting this togther. It saved my day.

  53. Adam P. says:

    THANKS. This is something I’ve wanted in Outlook for a long time. It seems like such a natural feature for Outlook, I don’t know why it isn’t included already. I’m inspired to write some macros for other functionality I’d like in Outlook and Office (it’ll be great for when I’m bored at work because it will look like I’m doing my actual job 😀 ).

    I also found this tip "How to turn an Outlook message into an appointment or a task" at http://blogs.techrepublic.com.com/msoffice/?p=281

    Basically you just drag the email from the Inbox (or folder view) to the Calendar shortcut and it creates a new message — atleast in Outlook 2007, not sure about older versions.

    So I guess this functionality is already included in Outlook, but I think that your solution is a little bit better. Your solution copies any attachments and adds the message recipients to the appointment. The one other thing that your solution does, which I think is the most important, which the drag/drop functionality doesn’t do is you can add a button to the Quick Lauch bar in the email message — the reason this is so important IMHO is that the workflow is better. If you have a message opened and you want to create an appointment from it, then you can do it from the same window without have to go back to the main window and drag/drop the messages you’re reading. I think this is a big productivity plus. Also your macro solution can be more customized to one’s particular needs and multiple versions can be made for different needs — for example, maybe the same conference room is always used, you always invite the same people, or you want to categorize it.

    Thanks again!

  54. Annie Brown says:

    Hi,

    Do any of y’all know of a macro that will create a "Business Contact" from an e-mail?

    When I right-click, I only have the option to save the contact to Outlook Contacts – which I’m not using – I have everything stored in BCM 2007.

    Please help!

    Annie

  55. grabani says:

    I’m not sure if it is only me but, when I use the macro it does not attach the original emails attachments to the invitation.

    Anybody else have the same problem (or solution/explanation)?

    Thanks in advance.

  56. Pounder says:

    Help.  Unable to get this code to work on Office 2K7.  Keep getting a runtime error ‘287’.  Applicaiton defined or object defined error.  

  57. Jess says:

    Thanks!!! My work just made the move from Lotus Notes to Outlook and I was really frustrated at the inability to make appointments from email. The macro worked like a charm!

    Cheers!

  58. Sara says:

    You dont need to write the macro or anything. just drag the message to the calendar  tab on the navigation side bar. it will open as an appointment for you where you nedd to add  date and invitees.

  59. Chalama says:

    Really useful and a great macro.

    Thanks!

  60. Ash says:

    you can drag the email from your inbox and drop it on the calendar pane and it should create an appointment. i guess the macro discussed in this article does a lot more like sending the appointment to the sender etc..but for the very basic needs the drag and drop should work….just thought i'd share

  61. Duane says:

    Thanks.  This should be normal funtionality in Outlook.  Wonderful macro.

  62. David says:

    As of October 2010, this macro still functions in Outlook 2003.  Thanks a lot!

  63. Arie says:

    Thanks.

    In Outlook 2003 the "send" button was not directly availble, to fix this I had to change the "appointment" into a "meeting request". This can be done by adding (after the "set meetingrequest = .." statement) the following line :

    meetingRequest.MeetingStatus = olMeeting

  64. Erin says:

    That is awesome… I wish I'd searched for this macro earlier!!

    Is there anything out there where I can change whose calendar it comes from? I support quite a few different people and create calendar invites all day.

    Thanks!!

  65. Juck says:

    Hi,

    I have to account in outlook 2003

    When I sent email I have to change my account from default to non default and then I am able to send email form second account

    I am looking for VBScript to create a macro button that when I click on it will open new message and should choose the non default account I mean second account

    Thanks A lot

  66. Michael says:

    Here's HOW TO MAKE IT WORK IN OFFICE 2007

    (at least the solution that worked for me)

    The problem appeared to be an issue with security settings.  Here is how I fixed it.

    1.  Follow the instructions on how to add a VBA Macro that Synergist posted:

    blogs.msdn.com/…/adding-a-vba-macro-to-outlook.aspx

    2. In Outlook, go to Tools -> Macro ->Security.  There are 4 choices:

    a.  No warnings and disable all macros.

    b. Warnings for signed macros; all unsigned macros are disabled.

    c.  Warnings for all macros.

    d.  No security check for macros.

    If you have (a) selected, this will not work no matter what because macros are disabled.

    You have to choose (b) (c) or (d).  

    If you select (c) or (d), no need to go further.  The macro will work, but your security settings are lax and vulnerable.  I don't recommend having your Outlook security settings here, but it's up to you.

    I personally have it set to (2) (Warnings for signed macros; all unsigned macros are disabled).  In this case, move on to the rest of the steps.

    3.  You're going to have to create a certificate for your Macro.

    Find the "Selfcert.exe" file on your computer.  It should be located:

    Program FilesMicrosoft OfficeOffice12

    or

    Program FilesMicrosoft OfficeOffice11

    4.  Run the "selfcert.exe" file.  Give your certificate a name.  Go ahead and name it after yourself, after your macro, after your dog…

    5.  Go back to Outlook.

    6.  Tools ->Macros -> Visual Basic Editor   (or just hit ALT+F11)

    7.  On the Project window, on the left side, find your macro.  It should be under "Modules" if you followed Step 1.  Select your macro.

    8. Go to  Tools -> Digital Signature

    9.  Under "sign as" select "choose."  You should see your Certificate that you created.  Select OK, OK.  Close the Visual Basic Editor and hit "save" if it prompts you.

    Hope this helps those Outlook 2007 users trying to create an outlook appointment based on an email message using the NewMeetingRequestFromEmail.bas macro.

    NOTE:  For some reason, the macro doesn't work from the "main" email screen.  It only works when you double-click and open an email, THEN run the macro.  When I run it from the Outlook mail screen (with the mail previews and all that), it doesn't work.

  67. Zdravko says:

    Hey guys,

    There is a way easier way to do it:

    "All you do is drag the e-mail from your Inbox to Outlook’s Calendar icon (usually located in the lower-left corner of the screen). That action creates a new appointment with the body of the e-mail in the notes section. Set the time and date as needed (Outlook can’t automatically pluck this info out of an e-mail, alas), tweak the subject line if necessary, and presto: You’re done."

    Taken from one web site 😉

  68. YT says:

    You can actually just drag and drop your email into Calendar folder and that will have same effect

  69. JW says:

    If you drag an email to the date on the calendar to the right it sets a new appointment for that date. You just have to adjust the time.

  70. Pnz says:

    Yes, you can drag and drop if the email isn't open, but I think the aim of the macro is to take an open email and turn it into an appointment…something Macs do very simply. One of the few things I like about Macs.

  71. Stijn says:

    Thanks! Works like a breeze! Have been copying email addresses around for way too long!

  72. Ric says:

    Great job!  Appreciate your hard work!  Using it and loving it.

  73. Marcelo says:

    This is awesome. Unbeliavable how MS didn't make this a native feature. Many thanks!

  74. Andrei Kovalev, Munich says:

    Just had an email I wanted to convert to a meeting. Found many entries in google for the same task. This one was on top of the search list. Downloaded BAS and imported into my Outlook VBA module.

    I am using Outlook 2007 with those Quick Toolbars…

    I found out that the macro works on the active opened email, so it makes sense to put the macro into the quick toolbar of the opened email.

    Works well.

    Once appointment item appears, one needs to click Appointment/Invite Attendees to make "Send" button appear. After that the appointment can be sent to the team.

  75. Felix Boehme says:

    Thanks for this!

    I modified it slightly so that the whole email gets attached (attachments included) rather than copying the text – I find this cleaner, as it preserves formatting etc.

    Also made it so that you don't have to click the Invite Attendees button to convert to a Meeting Invite – this step is now included in the macro, so you can just hit send.

    And I added two separate calling procedures — one that picks up the current email from the reading pane, and one that uses an open email. Just add the appropriate shortcut on the respective toolbars and you're set to go:

    (I preserved original code in comments, so you can revert back to that functionality if you prefer.)

  76. Felix Boehme says:

    Option Explicit

    Dim item As Object

    Sub NewMeetingReadingPane()

       Set item = Application.ActiveExplorer.Selection(1)

       NewMeetingRequestFromEmail

    End Sub

    Sub NewMeetingOpenEmail()

       Set item = Application.ActiveInspector.CurrentItem

       NewMeetingRequestFromEmail

    End Sub

    ' Create a New Meeting request from an email

    ' Written by Michael S. Scherotter (mischero@microsoft.com)

    ' 1. If the current item is an email, create a new appointment item

    ' 2. Copy the categories, body, and subject

    ' 3. Copy the attachments

    ' 4. Add the sender as a meeting participant

    ' 5. Add each email recipient as a meeting participant

    ' 6.    Each To: participant will be required

    ' 7.    Each CC: or BCC: participant will be optional

    Sub NewMeetingRequestFromEmail()

       Dim app As New Outlook.Application

       'Dim item As Object

       'Set item = app.ActiveInspector.CurrentItem

       'Set item = Application.ActiveExplorer.Selection(1)

       If item.Class <> olMail Then Exit Sub

       Dim email As MailItem

       Set email = item

       Dim meetingRequest As AppointmentItem

       Set meetingRequest = app.CreateItem(olAppointmentItem)

       meetingRequest.Categories = email.Categories

       'meetingRequest.Body = email.Body

       meetingRequest.Subject = email.Subject

       meetingRequest.Attachments.Add item, olEmbeddeditem

    '    Dim attachment As attachment

    '    For Each attachment In email.Attachments

    '        CopyAttachment attachment, meetingRequest.Attachments

    '    Next attachment

       Dim recipient As recipient

       Set recipient = meetingRequest.Recipients.Add(email.SenderEmailAddress)

       recipient.Resolve

       For Each recipient In email.Recipients

           RecipientToParticipant recipient, meetingRequest.Recipients

       Next recipient

       meetingRequest.MeetingStatus = olMeeting

       Dim inspector As inspector

       Set inspector = meetingRequest.GetInspector

       'inspector.CommandBars.FindControl

       inspector.Display

    End Sub

    Private Sub RecipientToParticipant(recipient As recipient, participants As Recipients)

       Dim participant As recipient

       If LCase(recipient.Address) <> LCase(Session.CurrentUser.Address) Then

           Set participant = participants.Add(recipient.Address)

           Select Case recipient.Type

           Case olBCC:

               participant.Type = olOptional

           Case olCC:

               participant.Type = olOptional

           Case olOriginator:

               participant.Type = olRequired

           Case olTo:

               participant.Type = olRequired

           End Select

           participant.Resolve

       End If

    End Sub

    Private Sub CopyAttachment(source As attachment, destination As Attachments)

       On Error GoTo HandleError

       Dim filename As String

       filename = Environ("temp") & "" & source.filename

       source.SaveAsFile (filename)

       destination.Add (filename)

       Exit Sub

    HandleError:

       Debug.Print Err.Description

    End Sub

  77. Mac User 89 says:

    There isn't a way to do this in Outlook 2011 for Mac users, I looked around for a bit and found a great program:

    "Appointment from Message for Outlook 2011 Mac" http://www.logicitc.com/products

  78. James_McS says:

    Open your calendar in a new Outlook window (right click, open in new window) and just drag the email into the calendar. Bingo!

  79. Frank Bender says:

    Unbelieveable that this feature is still missing in the so called "leading" PIM application. No wonder that it is so easy for other apps to gain market share.

  80. CHorse says:

    Wow, can't believe Microsoft has not provided a simple solution for end users.  We're moving from Lotus Notes to Outlook/Exchange and many of our people want a simple way to copy email to their calendar. This has been a Notes feature since forever.

  81. seve says:

    this simply emphasises the limitations, the paucity of outlook… having to use VBA / Macros to achieve common objectives… e.g. create an event from an email, no unified inbox, right click an email for reply – stone-age tech

  82. Lucas says:

    Hi Michael,

    is it possible to paste the full code? I am unable to open the .bas file.

    Thanks!

  83. Sharon says:

    Thanks so much for this code. It worked beautifully!