A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Problem with MAPIFolder.Items.Restrict(), C#, Outlook 2003 and ear



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 25th 07, 03:21 PM posted to microsoft.public.outlook.program_addins
OctopusThu
external usenet poster
 
Posts: 25
Default 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)
{
......
}


Ads
  #2  
Old January 26th 07, 07:36 AM posted to microsoft.public.outlook.program_addins
OctopusThu
external usenet poster
 
Posts: 25
Default 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)
{
......
}


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to restrict task editing and deletion in Outlook 2003 ? [email protected] Add-ins for Outlook 2 October 11th 06 02:30 PM
Outlook.MAPIFolder, VBA macros lerneree Outlook - Using Forms 0 September 6th 06 10:18 AM
how to retain 10 days items in Outlook 2003 deleted items folder? Balthazar Outlook - Installation 2 June 7th 06 04:05 PM
Restrict method problem Mike Epp Outlook and VBA 2 April 7th 06 07:03 PM
MapiFolder Items ItemChange is not firing AtulSureka Outlook - Using Forms 1 February 6th 06 04:32 PM


All times are GMT +1. The time now is 09:12 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.