locked
Getting the Appointment Object for a specific date of a recurring appointment in VSTO and C# RRS feed

  • Question

  • Hi,

    I am developing a Outlook Add-in using VSTO 4.0.

    I am facing a problem in getting the date of a occurrence of a recurring appointment in series mode.

    I want to save data for the occurrence when i opened that particular occurrence in appointment window. I am getting the particular date when I open the recurring appointment in this.occurrence mode. But the same I am not getting when I am opening in series mode.

    Can you please provide a solution to this problem.

     

    Thanks,

    Santosini Sahoo

    • Moved by Min Zhu Monday, October 3, 2011 12:59 AM (From:.NET Platform Architecture Development Discussions)
    Friday, September 30, 2011 5:17 AM

Answers

  • Hi Santosini,

     

    Thanks for posting in the MSDN Forum.

     

    Do you want to access the recurring appointment which will be occurred at a specific date? This snippet will show you how to access the recurrence appointment that will be occurred today.

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Outlook = Microsoft.Office.Interop.Outlook;
    
    namespace ConsoleApplication11
    {
        class Program
        {
            static void Main(string[] args)
            {
                Outlook.Application oApplication = new Outlook.Application();
                Outlook.NameSpace oSession = oApplication.Session;
                Outlook.MAPIFolder oCalendar = oSession.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
                foreach (object obj in oCalendar.Items)
                {
                    if (obj is Outlook.AppointmentItem)
                    {
                        Outlook.AppointmentItem oAppointmentItem = (Outlook.AppointmentItem)obj;
                        if (oAppointmentItem.IsRecurring)
                        {
                            Outlook.RecurrencePattern oRecurrencePattern = oAppointmentItem.GetRecurrencePattern();
                            if (oRecurrencePattern.PatternStartDate <= DateTime.Now && oRecurrencePattern.PatternEndDate >= DateTime.Now)
                                oAppointmentItem.Display();
                        }
                    }
                }
                Console.ReadKey();
            }
        }
    }
    

    I hope it can help you.

     

    Have a good day,

     

    Tom

     

     

     


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by 许阳(无锡) Tuesday, October 11, 2011 6:37 AM
    Tuesday, October 11, 2011 6:34 AM

All replies

  • Hi Santosini,

    Thanks for your post.

    I have moved this thread to Outlook for Developers forum where you can get better answers.

    Best regards,


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 3, 2011 12:59 AM
  • I am not sure I understand what you mean: what is the relevant snippet of your code? What does it produce? What is the expected behavior?
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/
    OutlookSpy - Outlook, CDO
    and MAPI Developer Tool
    Monday, October 3, 2011 1:12 AM
  • Hi Santosini,

     

    Thanks for posting in the MSDN Forum.

     

    Do you want to access the recurring appointment which will be occurred at a specific date? This snippet will show you how to access the recurrence appointment that will be occurred today.

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Outlook = Microsoft.Office.Interop.Outlook;
    
    namespace ConsoleApplication11
    {
        class Program
        {
            static void Main(string[] args)
            {
                Outlook.Application oApplication = new Outlook.Application();
                Outlook.NameSpace oSession = oApplication.Session;
                Outlook.MAPIFolder oCalendar = oSession.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
                foreach (object obj in oCalendar.Items)
                {
                    if (obj is Outlook.AppointmentItem)
                    {
                        Outlook.AppointmentItem oAppointmentItem = (Outlook.AppointmentItem)obj;
                        if (oAppointmentItem.IsRecurring)
                        {
                            Outlook.RecurrencePattern oRecurrencePattern = oAppointmentItem.GetRecurrencePattern();
                            if (oRecurrencePattern.PatternStartDate <= DateTime.Now && oRecurrencePattern.PatternEndDate >= DateTime.Now)
                                oAppointmentItem.Display();
                        }
                    }
                }
                Console.ReadKey();
            }
        }
    }
    

    I hope it can help you.

     

    Have a good day,

     

    Tom

     

     

     


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by 许阳(无锡) Tuesday, October 11, 2011 6:37 AM
    Tuesday, October 11, 2011 6:34 AM