Can InfoPath (2003 SP1) add an event in Outlook Calendar? - InfoPath Dev
in

InfoPath Dev

Can InfoPath (2003 SP1) add an event in Outlook Calendar?

Last post 11-02-2009 06:43 AM by sheep. 32 replies.
Page 2 of 3 (33 items) < Previous 1 2 3 Next >
Sort Posts: Previous Next
  • 07-08-2008 07:25 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hi, John -- I replied to your private message with my email so you can send me your form. Let me know if you didn't get my PM.

    Hilary Stoupa

  • 07-10-2008 02:39 AM In reply to

    • Ellya
    • Not Ranked
    • Joined on 07-10-2008
    • Posts 2

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hi Hilary,

    Great article! I took your code example and managed to get an entry into my Outlook calendar with a button click in my form.

    To take this further, rather than use hard coded date/time, what's the syntax for inserting a date/time field from my form into the "itmAppt.Start = "  line?

    Also (forgive all the questions, I'm fairly new to InfoPath!), how do you specify which outlook calendar to update? I would prefer to submit an entry to our team's shared calendar rather than my personal one.

    Your help is greatly appreciated.

     Cheers, Ellya

     

    Ellya Gold
    Research Machines UK
    Supporting Glow,
    The Scottish Schools Digital Network.
    _______________________
    Time is the best teacher.
    Shame it kills all its students!
  • 07-10-2008 07:47 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hello:

     To get your field value, you'll need to modify the xpath in the sample below to point to your field:

        Dim objOutlook
        Dim itmAppt
        Dim time
     
        Set objOutlook = CreateObject("Outlook.Application")
        Set itmAppt = objOutlook.CreateItem(1)
        Set time = XDocument.DOM.selectSingleNode("/my:myFields/my:field")


      itmAppt.Subject = "Subject"
      itmAppt.Start = time.text
      itmAppt.Duration = 60
      itmAppt.AllDayEvent = False
      itmAppt.ReminderSet = True
      itmAppt.ReminderMinutesBeforeStart = 15
      itmAppt.Save

    I'm afrraid I don't know how to select a specific calendar in Outlook. Here is a link to the Outlook Object Model on MSDN -- that may help: http://msdn.microsoft.com/en-us/library/aa221870(office.11).aspx and if I run across more information, I'll be sure to post it here.

    Hilary Stoupa

  • 07-10-2008 08:13 AM In reply to

    • Ellya
    • Not Ranked
    • Joined on 07-10-2008
    • Posts 2

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Many thanks for that, I'll give it a bash in a mo and let you know how I get on.

    Cheers, Ellya

     

    Ellya Gold
    Research Machines UK
    Supporting Glow,
    The Scottish Schools Digital Network.
    _______________________
    Time is the best teacher.
    Shame it kills all its students!
  • 11-13-2008 10:45 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hi Hilary,

    is it also possible to add particpants to an appointment via infopath? I tried itmAppt.CC but
    I failed.

    I found a solution:

    Sub CommandButton1_Click()
    Set myItem = Application.CreateItem(1)
    myItem.MeetingStatus = 1
    myItem.Subject = "Strategy Meeting"
    myItem.Location = "Conference Room B"
    myItem.Start = #9/24/03 1:30:00 PM#
    myItem.Duration = 90
    Set myRequiredAttendee = myItem.Recipients.Add ("Nate Sun")
    myRequiredAttendee.Type = 1
    Set myOptionalAttendee = myItem.Recipients.Add ("Kevin Kennedy")
    myOptionalAttendee.Type = 2
    Set myResourceAttendee = myItem.Recipients.Add("Conference Room B")
    myResourceAttendee.Type = 3

    myItem.Send
    End Sub

  • 11-14-2008 10:03 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    So was the Recipients.Add the way to go? If so, thanks for posting the answer to help others!

    Hilary Stoupa

  • 01-06-2009 05:28 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Hello Hilary!  I hope that you had a very Merry Christmas and a Happy New Year!  I spent my New Years Eve sipping Alka Seltzer and Robotussin!  All better now though.

    Anyway, I need to do this in C# and would greatly appreciate your expert assistance.

    Fishman
  • 01-06-2009 07:46 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    You'll have to remind me again of your preferred object model -- are you using 2003 or 2007?

    Hilary Stoupa

  • 01-06-2009 09:31 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Sorry...IP 2007 and OL 2007.

    Fishman
  • 01-06-2009 12:33 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    I found a fantastic sample here. Be sure to read the comments below the sample, since there were some issues / fixes.

    Basically, you'll need to add a reference to Microsoft.Office.Interop.Outlook to your project. Here is a little more info on how to do that. It's under the COM tab. Adding a using statement to the top of the code should keep you from having to preface every instance of 'Outlook' in this sample with 'Microsoft.Office.Interop". This is almost exactly the same code from the sample, with a few errors corrected. Note that your form will have to be full trust, and if you want to use info from your form as values for the appointment, you'll need to add that. I did try this locally, and it created an appointment in my calendar.

                //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:
     
                Outlook.Application outlookApp = new Outlook.Application();
     
                //Next, create an instance of AppointmentItem object and set the properties:
     
                Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem);
     
                oAppointment.Subject = "This is the subject for my appointment";
                oAppointment.Body = "This is the body text for my appointment";
                oAppointment.Location = "Appointment location";
     
                // Set the start date
                oAppointment.Start = Convert.ToDateTime("01/10/2009 10:00:00 AM");
                // End date
                oAppointment.End = Convert.ToDateTime("01/10/2009 2:00:00 PM");
                // Set the reminder 15 minutes before start
                oAppointment.ReminderSet = true;
                oAppointment.ReminderMinutesBeforeStart = 15;
     
                //Setting the sound file for a reminder:
                 oAppointment.ReminderPlaySound = true;
     
                //Setting the importance:
                //use OlImportance enum to set the importance to low, medium or high
     
                oAppointment.Importance = Outlook.OlImportance.olImportanceHigh;
     
                /* OlBusyStatus is enum with following values:
                olBusy
                olFree
                olOutOfOffice
                olTentative
                */
                oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy;
     
                //Finally, save the appointment:
     
                // Save the appointment
                oAppointment.Save();
    Hilary Stoupa

  • 01-06-2009 12:40 PM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Thanks Hilary!  I think that we may have found the same article - but I wasn't getting very far!  Full trust you say?  I hate that!  I'll give it a whirl.

    Fishman
  • 01-08-2009 11:41 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    I got it to work in my calendar like a charm, but you know that I can't just stop there.  Now i am trying to set one up in a calendar that someone has shared with me.  This is what I have so far, but it just keeps putting the appointment in my calendar.  Can you see where I am going wrong?

     

    //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("apcarroll"); 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);

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

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

    oAppointment.Location = "Appointment location";

    // Set the start date

    oAppointment.Start = Convert.ToDateTime("01/10/2009 10:00:00 AM");

    // End date

    oAppointment.End = Convert.ToDateTime("01/10/2009 2:00:00 PM");

    // Set the reminder 15 minutes before start

    oAppointment.ReminderSet = true;

    oAppointment.ReminderMinutesBeforeStart = 15;

    //Setting the sound file for a reminder:

    oAppointment.ReminderPlaySound = true;

    //Setting the importance:

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

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

    olBusy

    olFree

    olOutOfOffice

    olTentative

    */

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

    //Finally, save the appointment:

    // Save the appointment

    oAppointment.Save();

    }

    }

    Fishman
  • 01-08-2009 11:54 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Actually, I fixed it!  I got confused with my naming conventions.  Here is the final draft. 

    //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("apcarroll"); 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("01/10/2009 10:00:00 AM");

    // End date

    myAppointment.End = Convert.ToDateTime("01/10/2009 2:00:00 PM");

    // 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;

    //Finally, save the appointment:

    // Save the appointment

    myAppointment.Save();

    Fishman
  • 10-25-2009 01:19 AM In reply to

    • sheep
    • Not Ranked
    • Joined on 10-24-2009
    • Posts 7

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

     

    Hi!

    thanx for this interesting information.

    I have a question.

    can " Subject" be changed by a written input of a textbox?

    Kind regards

  • 10-26-2009 04:25 AM In reply to

    Re: Can InfoPath (2003 SP1) add an event in Outlook Calendar?

    Yes. Set the value of the myAppointment.Subject property to the path of the textbox that contains the text that will be the subject of the appointment.
    Fishman
Page 2 of 3 (33 items) < Previous 1 2 3 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.