Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get unread Mails from Outlook

Tags:

c#

.net

outlook

Is there any way to get all mail from an specific Folder into my Application?

like image 200
Phil Avatar asked Jan 13 '10 10:01

Phil


People also ask

Why can't I see my unread emails in Outlook?

This usually happens because of one of the following reasons: You have Focused Inbox enabled. You have a filter applied to your view. You are not allowed to see private items in a shared mailbox.

How do I find my unread emails?

Open your Gmail app. Tap the section that says Search in emails at the top of the screen. Type in “is:unread in:inbox” and press Search. All your unread emails will appear on the display.


1 Answers

Check this link. Introduction to Outlook Programming will explain things more clearly.

You could loop through the mailitems. Sample code

using System.Runtime.InteropServices;
using OutLook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;

    OutLook.Application oApp;
             OutLook._NameSpace oNS;
             OutLook.MAPIFolder oFolder;
             OutLook._Explorer oExp;

             oApp = new OutLook.Application();
             oNS = (OutLook._NameSpace)oApp.GetNamespace("MAPI");
             oFolder = oNS.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderInbox);
             oExp = oFolder.GetExplorer(false);
             oNS.Logon(Missing.Value, Missing.Value, false, true);

        OutLook.Items items = oFolder.Items;
        foreach (OutLook.MailItem mail in items)
                        {

                            if (mail.UnRead == true)
                            {
                        }
        }

Edit: Reference other folders

oFolder.Folders["Foldername"]

OutLook Code

Common Outlook tasks

like image 169
PRR Avatar answered Oct 08 '22 19:10

PRR