How can I convert System.DateTime to vbDate? (using CDO 1.2.1, MAPI.MessageFilter)

rosesa used Ask the Experts™
I try to read my outlook calendar items using MAPI and the MessageFilter Object.

My code snippet:

private int CdoDefaultFolderCalendar = 0;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private MAPI.Session objSession;


MAPI.Folder objCalendarFolder = (MAPI.Folder) objSession.GetDefaultFolder(CdoDefaultFolderCalendar);
MAPI.Messages objMessColl = (MAPI.Messages) objCalendarFolder.Messages;
MAPI.MessageFilter objMessFilterColl = (MAPI.MessageFilter) objMessColl.Filter;
objMessFilterColl.TimeFirst = dateTimePicker1.Value.Date;

I get the error message:


 [Collaboration Data Objects - [MAPI_E_TOO_COMPLEX(80040117)]]

Thanks for your help.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


Converts a DateTime to an Ole Automation date


I tried:
objMessFilterColl.TimeFirst = dateTimePicker1.Value.Date.ToOADate();
but the same error message appears.

Then the error is not to do with the date
The function I gave you converts the System.DateTime to a date that is compliant with VB, COM and MS Office
I use it when interopping with Excel 10
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

This error message is returned from MAPI (along with the error MAPI_E_NO_SUPPORT) when a MAPI feature you are trying to use is not mandatory: i.e. it has not been implemented in the server you are using.
From my previous work with MAPI there is lots of documented functionality that doesn't actually work in most MAPI implementations.
Which line causes the error?



You are right. The dates are not the problem.

my code is:
1: objMessFilterColl.TimeFirst = dateTimePicker1.Value.Date.ToOADate();
2: objMessFilterColl.TimeLast = dateTimePicker2.Value.Date.ToOADate();
3: textBox1.Text = textBox1.Text + objMessColl.Count;

and the error occurs in line 3:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Additional information:  [Collaboration Data Objects - [MAPI_E_TOO_COMPLEX(80040117)]]

So this filer functionality is not implemented on my server?
What should I do?

Loop though the mail items, checking the properties of each
Seems to be about the only suggestion ...


Thanks for helping me.
I have 2.147.483.647 Items. Is that ok?

I think it's going to take a very long time
What mail server are you using? Can you change this?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial