Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
how to create an application send and receive as outlook by c#
example:
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 16:02pm
Rate this: bad
good
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;
            }
        }
  Permalink  
Comments
Tuấn Ngọc at 30-Nov-12 2:59am
   
can you give me a demo about it ? or posts talk about it ?
Raman Thakur at 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 at 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 at 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 =
(MailItem)olkApp1.CreateItem(OlItemType.olMailItem);
olkMail1.To = txtpsnum.Text;
olkMail1.CC = "";
olkMail1.Subject = "Assignment note";
olkMail1.Body = "Assignment note";
olkMail1.Attachments.Add(AssignNoteFilePath,
Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 1,
"Assignment_note");
olkMail1.Save();
Raman Thakur at 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 = "Abc@xyz.com";
vMailItem.CC = "CCMailID@xyz.com";
vMailItem.Subject = "MeetingSubject";
vMailItem.Body = "MeetingBody";
vMailItem.Display(true);

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



Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 30 Nov 2012
Copyright © CodeProject, 1999-2014
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