Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   Problem with MAPIFolder.Items.Restrict(), C#, Outlook 2003 and ear (http://www.outlookbanter.com/add-ins-outlook/38872-problem-mapifolder-items-restrict-c.html)

OctopusThu January 25th 07 03:21 PM

Problem with MAPIFolder.Items.Restrict(), C#, Outlook 2003 and ear
 
I want to aquire all items in the folder that starts later than a specified
time. How can I use the Restrict method to achieve this?

In MSDN, there is a VB example:

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

But how about C#?
I tried using String.Format with the following code but failed:

Outlook.Items appointmentItems;
try
{
string strStartTime = String.Format(startTime.ToString(),
"ddddd h:nn AMPM");
appointmentItems = folder.Items.Restrict("[MessageClass] =
'IPM.Appointment'");
appointmentItems = folder.Items.Restrict("[Start] = '" +
strStartTime + "'"); //Exception occurred here
}
catch(Exception ex)
{
......
}



OctopusThu January 26th 07 07:36 AM

Problem with MAPIFolder.Items.Restrict(), C#, Outlook 2003 and ear
 
I have figured it out myself. Just use:

DateTime.ToString("yyyy-MM-dd HH:mm");

"OctopusThu" wrote:

I want to aquire all items in the folder that starts later than a specified
time. How can I use the Restrict method to achieve this?

In MSDN, there is a VB example:

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

But how about C#?
I tried using String.Format with the following code but failed:

Outlook.Items appointmentItems;
try
{
string strStartTime = String.Format(startTime.ToString(),
"ddddd h:nn AMPM");
appointmentItems = folder.Items.Restrict("[MessageClass] =
'IPM.Appointment'");
appointmentItems = folder.Items.Restrict("[Start] = '" +
strStartTime + "'"); //Exception occurred here
}
catch(Exception ex)
{
......
}




All times are GMT +1. The time now is 03:41 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com