Is this an outside program or a COM addin?
In either case I'd recommend setting NameSpace by using GetNameSpace("MAPI")
and not just by referencing Session. Although I don't think that has
anything to do with your problem.
Does the code run all the way through with no exceptions? Have you been able
to step the code in debug mode and see what's happening? What about
diagnostic logging, are you doing any so you can check at various
checkpoints to see what values are there for key objects such as your filter
string, the default item type for the folder selected from PickFolder(), the
raw count of both the filtered and unfiltered Items collections, etc?
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"Mk23" <(E-Mail Removed)> wrote in message
news:36289404-28C6-45F8-B463-(E-Mail Removed)...
> Hi
>
> I have a problem by getting the appointment from an calendar folder. I use
> the PIA from Office XP and have a Outlook 2007. At the most customer it
> works
> fine, but at a few PC's it doesn't work. That mean, i get no appointment
> items, althought the user has a lot of them in his calendar.
>
> I get the items by the following sample code:
>
> //Select folder
> Microsoft.Office.Interop.Outlook.Application app = new
> Microsoft.Office.Interop.Outlook.Application();
> NameSpace olNameSpace = app.Session;
> olFolder = olNameSpace.PickFolder();
>
> //Create filter string
> CultureInfo userCulture = new
> CultureInfo(GetUserDefaultLCID());
> string restrictExpression = string.Format("[Start]>='{0}' AND
> [Start]<'{1}'",
> _dateFrom.Value.ToString("g", userCulture.DateTimeFormat),
> _dateTill.Value.ToString("g", userCulture.DateTimeFormat));
>
> //Get filtered items and sort them
> Items folderItems = olFolder.Items;
> Items restrictedItems =
> folderItems.Restrict(restrictExpression);
> restrictedItems.Sort("[Start]", Missing.Value);
>
> //Loop all appointment elements
> object itemObject = restrictedItems.GetFirst();
> while (itemObject != null)
> {
> ...
> }
>
> Does anyone have an hint for me
>
> Regards
> Thomas