Click here to Skip to main content
12,819,019 members (27,253 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# C#4.0
how to create an application send and receive as outlook by c#
if it is the first, app will read all email, but if it is the second , app only read mail unread ???
Posted 29-Nov-12 17:02pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

BY using Microsoft.Office.Interop.Outlook;

you can Read/Write/Delete all the feature of outlook.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
            Outlook.MAPIFolder deletedFolder = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems);
           deletedFolder.Items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(DeletedItems_ItemAdd);


        void DeletedItems_ItemAdd(object Item)
            if (Item is Outlook.MailItem)
                (Item as Outlook.MailItem).UnRead = false;
            else if (Item is Outlook.AppointmentItem)
                (Item as Outlook.AppointmentItem).UnRead = false;
            else if (Item is Outlook.MeetingItem)
                (Item as Outlook.MeetingItem).UnRead = false;
            else if (Item is Outlook.ContactItem)
                (Item as Outlook.ContactItem).UnRead = false;
            else if (Item is Outlook.JournalItem)
                (Item as Outlook.JournalItem).UnRead = false;
            else if (Item is Outlook.TaskItem)
                (Item as Outlook.TaskItem).UnRead = false;
            else if (Item is Outlook.TaskRequestItem)
                (Item as Outlook.TaskRequestItem).UnRead = false;
            else if (Item is Outlook.PostItem)
                (Item as Outlook.PostItem).UnRead = false;
            else if (Item is Outlook.PostItem)
                (Item as Outlook.PostItem).UnRead = false;
Tuấn Ngọc 30-Nov-12 2:59am
can you give me a demo about it ? or posts talk about it ?
Raman Thakur 30-Nov-12 3:50am
first of tell me whats your requirement. You want to send email from c# using smtp or you want to use existing outlook to send mail and read outlook?
Tuấn Ngọc 1-Dec-12 6:34am
i want to use existing outlook to send mail and read outlook. the better if it have interface of outlook
Raman Thakur 5-Dec-12 6:11am
add refrence of using Outlook.Microsoft.Office.Interop.Outlook;

the send like below:
Microsoft.Office.Interop.Outlook.Application olkApp1 =
new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem olkMail1 =
olkMail1.To = txtpsnum.Text;
olkMail1.CC = "";
olkMail1.Subject = "Assignment note";
olkMail1.Body = "Assignment note";
Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 1,
Raman Thakur 12-Dec-12 5:02am
Microsoft.Office.Interop.Outlook.Application oApplication = new Microsoft.Office.Interop.Outlook.Application();
MailItem vMailItem = oApplication.CreateItem(OlItemType.olMailItem) as MailItem;
vMailItem.To = "";
vMailItem.CC = "";
vMailItem.Subject = "MeetingSubject";
vMailItem.Body = "MeetingBody";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170308.1 | Last Updated 30 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100