DotNet MAPI Microsoft.Office.Interop.Outlook.MailItem

azatothazatoth Member Posts: 31
edited 2014-07-10 in NAV Three Tier
Good morning,

I'm trying to do some code to loop through Outlook Inbox items for Mail Logging.

This is the code:
ApplicationClass@1000000000 : DotNet "'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.ApplicationClass";
Application@1000000001 : DotNet "'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.Application";
Namespace@1000000008 : DotNet "'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.NameSpace";
Inbox@1000000018 : DotNet "'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.MAPIFolder";
OlDefaultFolders@1000000019 : DotNet "'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.OlDefaultFolders";
MailSubject@1000000020 : Text;
Items@1000000014 : DotNet "'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.Items";
MailItem@1000000017 : DotNet "'Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.Microsoft.Office.Interop.Outlook.MailItem";

Application := ApplicationClass.ApplicationClass;
Namespace := Application.GetNamespace('MAPI');
Namespace.Logon('','',FALSE,FALSE);
OlDefaultFolders := OlDefaultFolders.olFolderInbox;
Inbox := Namespace.GetDefaultFolder(OlDefaultFolders);
Items := Inbox.Items;
MailItem := Items.GetFirst;

But on the line "MailItem := Items.GetFirst;" I get this error message:

Screenshot_10_07_2014_08_56_01.png

What is wrong with this code?
Sign In or Register to comment.