Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
https://i.stack.imgur.com/8xXEn.png[^]

I want to create meeting appointment request like shown in image using c# (wpf app) and open it in outlook window.

also want to save appointment into calendar

What I have tried:

Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); ;
            Microsoft.Office.Interop.Outlook.AppointmentItem newAppointment = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

            newAppointment.Start = DateTime.Now.AddHours(2);
            newAppointment.End = DateTime.Now.AddHours(3);
            newAppointment.Location = "http://xyz.co/join/7235253940223 ";
            newAppointment.Body ="jigi is inviting you to a scheduled XYZ meeting. ";
            newAppointment.AllDayEvent = false;
            newAppointment.Subject = "XYZ";
            newAppointment.Recipients.Add("Roger Harui");
            Microsoft.Office.Interop.Outlook.Recipients sentTo = newAppointment.Recipients;
            Microsoft.Office.Interop.Outlook.Recipient sentInvite = null;
            sentInvite = sentTo.Add("Holly Holt");
            sentInvite.Type = (int)Microsoft.Office.Interop.Outlook.OlMeetingRecipientType.olRequired;
            sentInvite = sentTo.Add("David Junca ");
            sentInvite.Type = (int)Microsoft.Office.Interop.Outlook.OlMeetingRecipientType.olOptional;
            sentTo.ResolveAll();
            newAppointment.Save();
            newAppointment.Display(true);


Output:

https://i.stack.imgur.com/Clh0d.png[^]

note : I tried few solution but i'm not getting send button and also from and to option.
Posted
Updated 5-May-21 23:23pm
v2

To set an appointment item as a meeting request, you must set the MeetingStatus property to olMeeting.

C#
newAppointment.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting;
 
Share this answer
 
Comments
Member 13135651 2-Feb-18 2:31am    
Thank You So Much.
private void AddAppointment()
       {
           try
           {
               Microsoft.Office.Interop.Outlook.Application otApp = new Microsoft.Office.Interop.Outlook.Application();
               Microsoft.Office.Interop.Outlook.AppointmentItem oAppointment = (Microsoft.Office.Interop.Outlook.AppointmentItem)otApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
               oAppointment.Subject = "[FSRAMS] Laptop Loan Due for return.";
               oAppointment.Body = "Please contact customer  to return their loan device.";
               oAppointment.Start = Convert.ToDateTime(DateTime.Now.AddHours(1));
               oAppointment.End = Convert.ToDateTime(DateTime.Now.AddDays(1));
               oAppointment.ReminderSet = true; // Set the reminder
               oAppointment.ReminderMinutesBeforeStart = 15; // reminder time
               oAppointment.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh; // appointment importance
               oAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;
               oAppointment.Save();
           }

           catch (Exception ex)
           {
               MessageBox.Show("The following error occurred: " + ex.Message);
           }
 
Share this answer
 
Comments
CHill60 6-May-21 5:40am    
Some of the reasons for my downvote
- AddDays returns a DateTime so there is no need to convert the result to a DateTime
- If you are going to convert anything to a DateTime you should use TryParse or TryParseExact to avoid the risk of exceptions.
- An uncommented code dump does not make a good solution
- You have not set the MeetingStatus option so this won't work properly

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900