Need help with my code C# to help to send meeting request through an Infopath form - InfoPath Dev
in

InfoPath Dev

Need help with my code C# to help to send meeting request through an Infopath form

Last post 02-24-2010 06:42 AM by bigJessetd. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 02-24-2010 06:42 AM

    Need help with my code C# to help to send meeting request through an Infopath form

    I am trying to add a feature to a form where a meeting request is generated from form data.  I can get the code to add an entry to my calender or anyone I share a calendar with but can not seem to get the add reciepents feature to work. 

    The code below was originally posted by BuildPro Guru and I modified it to try to acomplish a meeting request.

    http://www.infopathdev.com/forums/t/8341.aspx?PageIndex=2

    The code for the meeting request was from the MSDN site but I just can not get it to work. 

     Any help would be appreciated.

    public void CTRL1_5_Clicked(object sender, ClickedEventArgs e)

    {

    //First thing you need to do is add a reference to Microsoft Outlook 12.0 Object Library. Then, create new instance of Microsoft.Office.Interop.Outlook.Application object:

    Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();

    // Get the namespace

    Microsoft.Office.Interop.Outlook.NameSpace ns = outlookApp.GetNamespace("MAPI");

    // Create a receipient object that is going to be the organizer of the appointment

    Microsoft.Office.Interop.Outlook.Recipient myOrganizer = ns.CreateRecipient("jessed");

    myOrganizer.Resolve();

     

     

    // Open the shared calendar for the receipient

    Microsoft.Office.Interop.Outlook.MAPIFolder sharedCalendar = ns.GetSharedDefaultFolder(myOrganizer, Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);Microsoft.Office.Interop.Outlook.AppointmentItem myAppointment = (Microsoft.Office.Interop.Outlook.AppointmentItem)sharedCalendar.Items.Add(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

     

     

     

    //Next, create an instance of AppointmentItem object and set the properties:

    //Microsoft.Office.Interop.Outlook.AppointmentItem oAppointment = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

    myAppointment.Subject = "This is the subject for my appointment";

    myAppointment.Body = "This is the body text for my appointment";

    myAppointment.Location = "Appointment location";

    // Set the start date

    myAppointment.Start = Convert.ToDateTime("02/25/2010 10:00:00 AM");

    // End date

    myAppointment.End = Convert.ToDateTime("02/25/2010 2:00:00 PM");

    //Add attendees

     

     

    // Set the reminder 15 minutes before start

    myAppointment.ReminderSet = true;

    myAppointment.ReminderMinutesBeforeStart = 15;

    //Setting the sound file for a reminder:

    myAppointment.ReminderPlaySound = true;

    //Setting the importance:

    //use OlImportance enum to set the importance to low, medium or high

    myAppointment.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;/* OlBusyStatus is enum with following values:

    olBusy

    olFree

    olOutOfOffice

    olTentative

    */

    myAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olBusy;

     

    //Add invited attendees

    Microsoft.Office.Interop.Outlook.AppointmentItem myAttendee = myAppointment.items.Add("bryanw");myAttendee.Type = (int)Microsoft.Office.Interop.Outlook.OlMeetingRecipientType.olOptional;

    myAppointment.Recipients.ResolveAll();

     

    // Save the appointment

    myAppointment.Save();

     

     

     

    }

Page 1 of 1 (1 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.