PC Review


Reply
Thread Tools Rate Thread

Calender folder returns no appointments

 
 
Mk23
Guest
Posts: n/a
 
      17th Mar 2009
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
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      17th Mar 2009
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:(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


 
Reply With Quote
 
 
 
 
Mk23
Guest
Posts: n/a
 
      17th Mar 2009
Hi Ken

- The main application is a COM addin. But i wrote a smal sample project
with just the necessary code to get the calendar item. This sample is an
outside program. I can reproduce the error with both.
- The code run through with no exception.
- I ckeck the item type for the folder, so that it has to be a calendar.
- I can't reproduce the exception at an own system, only at the customer.
There I'am not able to debug.
- I have made a few logging to see the state of some object's.

That for the moment. I will post a few more info's when i have all
information you asked for.
 
Reply With Quote
 
Mk23
Guest
Posts: n/a
 
      18th Mar 2009
Hi Ken

Here I have a few more Informations from the customer log:
DefaultItemType: olAppointmentItem
restriction expression: [Start]>='18.02.2009 00:00' AND
[Start]<'18.05.2009 00:00'
UnfilteredItems: 404
FilteredItems: 0

So it seems to be a problem with the restriction expression. How has this
string to be formated, that it work?

I checked this string at my own system, there I have the same string and it
work's fine. My personal log:
restriction expression: [Start]>='18.02.2009 00:00' AND [Start]<'18.05.2009
00:00'
UnfilteredItems: 405
FilteredItems: 124

Regards Thomas
 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      18th Mar 2009
The VBA Object Browser Help on Restrict says you should format the date
string so it's formatted as Outlook expects. The example there is this,
using LastModificationTime as the field in the filter:

sFilter = "[LastModificationTime] > '" & Format("1/15/99 3:30pm", "ddddd
h:nn AMPM") & "'"

--
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:(E-Mail Removed)...
> Hi Ken
>
> Here I have a few more Informations from the customer log:
> DefaultItemType: olAppointmentItem
> restriction expression: [Start]>='18.02.2009 00:00' AND
> [Start]<'18.05.2009 00:00'
> UnfilteredItems: 404
> FilteredItems: 0
>
> So it seems to be a problem with the restriction expression. How has this
> string to be formated, that it work?
>
> I checked this string at my own system, there I have the same string and
> it
> work's fine. My personal log:
> restriction expression: [Start]>='18.02.2009 00:00' AND
> [Start]<'18.05.2009
> 00:00'
> UnfilteredItems: 405
> FilteredItems: 124
>
> Regards Thomas


 
Reply With Quote
 
Mk23
Guest
Posts: n/a
 
      18th Mar 2009
Yes this hint i have seen also.
But this can't be true, because inside the 'AMPM' part of this format string
the 'M' character will be replaced with the Minute part of the formated Date
(tested in C#)!
 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      18th Mar 2009
C# is not VBA. You must use the equivalent formatting that is appropriate
for C#. Run the line used in the example in Outlook VBA code and see that it
doesn't use the M of AMPM in the way you describe.

--
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:(E-Mail Removed)...
> Yes this hint i have seen also.
> But this can't be true, because inside the 'AMPM' part of this format
> string
> the 'M' character will be replaced with the Minute part of the formated
> Date
> (tested in C#)!


 
Reply With Quote
 
Mk23
Guest
Posts: n/a
 
      23rd Mar 2009
Hi Ken

Naturally you have right with the replacement, sorry.

But on the other side it doesn't help anything if I format the string the
way you/the help discribe. It is still the same, it doesn't work.

The formated string was:
[Start]>='2/19/2009 12:00 AM' AND [Start]<'5/19/2009 12:00 AM'

Regards Thomas

"Ken Slovak - [MVP - Outlook]" wrote:

> C# is not VBA. You must use the equivalent formatting that is appropriate
> for C#. Run the line used in the example in Outlook VBA code and see that it
> doesn't use the M of AMPM in the way you describe.
>
> --
> 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:(E-Mail Removed)...
> > Yes this hint i have seen also.
> > But this can't be true, because inside the 'AMPM' part of this format
> > string
> > the 'M' character will be replaced with the Minute part of the formated
> > Date
> > (tested in C#)!

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      23rd Mar 2009
All I can suggest is to use Debug.WriteLine() to show the filter you end up
with in C# and then use the original VBA code and see what that filter looks
like. Make sure they look the same. Also make sure that the VBA code works
as expected when you run it using that filter.

--
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:(E-Mail Removed)...
> Hi Ken
>
> Naturally you have right with the replacement, sorry.
>
> But on the other side it doesn't help anything if I format the string the
> way you/the help discribe. It is still the same, it doesn't work.
>
> The formated string was:
> [Start]>='2/19/2009 12:00 AM' AND [Start]<'5/19/2009 12:00 AM'
>
> Regards Thomas


 
Reply With Quote
 
Mk23
Guest
Posts: n/a
 
      25th May 2009
At the end we placed a call to microsoft.
We tried a lot of things, but didn't find the reason, for this strange
behaviour. In the end we deleted the profile of the user and it worked again.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Public folder calender "overlay" onto personal calender Richard Edwards Microsoft Outlook 2 10th Apr 2006 02:13 PM
link a network share calender with a personal calender so the the. =?Utf-8?B?bWF0dA==?= Microsoft Outlook Discussion 0 26th Apr 2005 05:28 PM
Missing Name in other Calender when choosing this Calender =?Utf-8?B?Sm9sYW5kYSBadWlkaG9law==?= Microsoft Outlook 0 2nd Mar 2005 02:51 PM
Calender in Outlook today vs Calender in personal folder Tobias Gårdner Microsoft Outlook Calendar 0 8th Feb 2005 09:16 AM
How Can I Share My Calender With another Calender ? =?Utf-8?B?TWF0Y2hMZXNz?= Microsoft Outlook Discussion 2 24th Jul 2004 09:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 AM.