How do I create and send appointments to Microsoft Outlook calender?

12,165

Solution 1

After you have the appointment:

Outlook.MailItem mailItem = appt.ForwardAsVcal();
mailItem.To = "recipient's email address";
mailItem.Send();

Solution 2

Try adding:

appt.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting;

Default status is an appointment which I'm not sure is being sent.

Solution 3

Here is how I fixed this issue :

I put (like Sonny Boy's post) :

Outlook.MailItem mailItem = appt.ForwardAsVcal();
mailItem.To = "[email protected]";
mailItem.Send();

But I also had to create a web.config file, and to set up the authorization access to avoid any COMException :

<system.web>
  <authorization>
    <deny users="?"/>
  </authorization>
</system.web>
Share:
12,165
Dushan Perera
Author by

Dushan Perera

❤️ building super 🚅 fast 🏎️ web experience 🚀 Azure functions &lt;⚡&gt; is my recent area of interest. Former ASP.NET MVP Please feel free to suggest improvements to my posts

Updated on June 08, 2022

Comments

  • Dushan Perera
    Dushan Perera almost 2 years

    I am trying to create an appointment in the Microsoft Outlook (2003) calender of another person using the below code.While running this program, The Appointment is getting saved in my calender.But not being sent to the recipient.

    try
    {
        Microsoft.Office.Interop.Outlook.Application app = null;
        Microsoft.Office.Interop.Outlook.AppointmentItem appt = null;
    
        app = new Microsoft.Office.Interop.Outlook.Application();
    
        appt = (Microsoft.Office.Interop.Outlook.AppointmentItem)app
            .CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
        appt.Subject = "Meeting ";
        appt.Body = "Test Appointment body";
        appt.Location = "TBD";
        appt.Start = Convert.ToDateTime("12/23/2009 05:00:00 PM");
        appt.Recipients.Add("[email protected]");
        appt.End = Convert.ToDateTime("12/23/2009 6:00:00 PM");
        appt.ReminderSet = true;
        appt.ReminderMinutesBeforeStart = 15;
        appt.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;
        appt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
        appt.Save();
        appt.Send();
    }
    catch (COMException ex)
    {
        Response.Write(ex.ToString());
    }
    

    Am i missing anything? Can any one help me out to solve this issue?