The following code can get Inbox, Shared EmailBox, PST files and search emails.
//Get namespace
Outlook.NameSpace thisNS = Application.ActiveExplorer().Session;
//Get Inbox folder:
Outlook.Folder inbox = thisNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) as Outlook.Folder;
//Get Shared mailbox
Outlook.Store shared = thisNS.Stores["Shared Emailbox"];
or
Outlook.Folder shared = thisNS.Folders["Shared Emailbox"] as Outlook.Folder;
//Search Emails
var search = from mail in inbox.Items.OfType<Outlook.MailItem>()
where mail.Subject.Contains("Test")
orderby mail.ReceivedTime descending
select mail;
References:
http://msdn.microsoft.com/en-us/library/ff458122(v=office.14).aspx
No comments:
Post a Comment