Outlook 2000 InvalidCast Exception

J

Jochen Stuempfig

Hello

i try to create an Outlook Mailitem using the Microsoft Outlook Library 9.0
for Outlook 2000.
My Code looks like this:

Outlook.Application oApp = new Outlook.Application();

Outlook._NameSpace oNameSpace = oApp.GetNamespace("MAPI");

oNameSpace.Logon(null, null, true, true);

Outlook.MAPIFolder oOutboxFolder =
oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);

Outlook._MailItem oMailItem =
(Outlook._MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

oMailItem.SaveSentMessageFolder = oOutboxFolder;

oMailItem.Save();



In the line where i try to create an new Mailitem i get an
InvalidCastException. Can anybody help me with this problem.



greets jochen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top