Reputation: 1336
I'm trying to get the body(or any other attribute) of an email which is inside a specific folder in outlook.
I'm using the interop.outlook
assembly.
I have done the following so far. But when trying to call an item in myInbox
, there are no attributes at all.
Application myApp = new ApplicationClass();
NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders["QC"];
The following brings no expected attributes
myInbox.Items[1].
In addition, the next step is to click a link inside the body of the email. just want to know if it's even possible.
Any help will be much appreciated.
Upvotes: 1
Views: 3795
Reputation: 3131
This is how I'm doing;
Outlook.Application myApp = new Outlook.Application();
Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).Folders["QC"];
This should bring all mails in Inbox. Then call;
Outlook.MailItem mailItem = myInbox.Items[1];
This mailItem
contains all the attributes you need.
Explanation: The mailFolder.Items[1]
is an Outlook.Items
object which has no attributes you require. You need to cast it to an Outlook.MailItem
object to achieve this.
Upvotes: 2