SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

Exchange 2007 Web Services - Get Calendar Items

Last post 08-19-2008, 10:05 by riccardospagni. 1 replies.
Sort Posts: Previous Next
  •  08-11-2008, 16:07 13961

    Exchange 2007 Web Services - Get Calendar Items

    Hi

    I'm trying to build a simple console app as a POC to pull all calendar items for my personal calendar. Firstly, the documentation from MS is p!ss poor, and the little code snippets i've been able to find don't seem to help.

    class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Starting Query...");
                var startTime = DateTime.Now;

                var esb = new ExchangeServiceBinding();
                esb.Credentials = CredentialCache.DefaultCredentials;

                var fit = new FindItemType();
                fit.ItemShape = new ItemResponseShapeType { BaseShape = DefaultShapeNamesType.Default };
                var path = new PathToUnindexedFieldType { FieldURI = UnindexedFieldURIType.itemSubject };
                fit.ItemShape.AdditionalProperties = new PathToUnindexedFieldType[1] { path };
                fit.ParentFolderIds = new DistinguishedFolderIdType[]
                {
                    new DistinguishedFolderIdType {
                        Mailbox = new EmailAddressType { EmailAddress="myemail@mydomain.com" },
                        Id = DistinguishedFolderIdNameType.calendar}
                };
                fit.Traversal = ItemQueryTraversalType.Shallow;         

                var firt = esb.FindItem(fit);

                foreach (var item in firt.ResponseMessages.Items)
                {
                    Console.WriteLine(item.MessageText);
                }

                var time = DateTime.Now.Subtract(startTime);
                Console.WriteLine();
                Console.WriteLine(String.Format("Finished in {0} milli seconds", time.Milliseconds));
                Console.ReadLine();
            }
        }

     This bombs on the web service call (var firt = esb.FindItem(fit);) - with the following error message:

     Path property must be set before calling the Send method.

     I can't seem to find any property to set to provide a path. Can anyone help out here?

     

  •  08-19-2008, 10:05 14104 in reply to 13961

    Re: Exchange 2007 Web Services - Get Calendar Items

    Have a read through this: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1090338&SiteID=17

     

    His issues revolved around serialization and impersonation, but he had issues with FindItem. He resolved it thus: "I got it to work. I just passed the esb into the function call". Having never used ExchangeServiceBinding, I'm probably not the best person to answer this, but perhaps that post will be a little more revealing?


    And so the kief looked and lo, it was kief.
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems