Click here to Skip to main content
Click here to Skip to main content

Get Outlook 07 email & attachments entry ID using C#.NET

By , 24 Apr 2010
 
Introduction
 
VBA developers are very much familiar with the features of Microsoft .NET platform to develop custom AddIn for Office system... This tip is about to get an Outlook email entry id & programmatic way to retrieve the attachments and store into another location. A sample code example is given below:
 
Example:
 
private Outlook.Inspectors Inspectors;
 
        private string _id;
        public string Id
        {
            get { return _id; }
            set { _id = value; } 
        }
 
private void ThisAddIn_Startup(object sender, System.EventArgs e)
  {
   Inspectors = this.Application.Inspectors;
   Inspectors.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(GetMessageID);
 }
 
private void GetMessageID(Microsoft.Office.Interop.Outlook.Inspector Inspector)
{
      string strMsgID = string.Empty;
 
      Outlook.MailItem _ObjMailItem = (Outlook.MailItem)Inspector.CurrentItem;
 
      if (Inspector.CurrentItem is Outlook.MailItem)
         {
            _ObjMailItem = (Outlook.MailItem)Inspector.CurrentItem;
            strMsgID = _ObjMailItem.EntryID;
  
            foreach (Outlook.Attachment _attachment in _ObjMailItem.Attachments)
                {
  	            _attachment.SaveAsFile(@"c:/TemP/" 
                                         + strMsgID 
                                         + "-"
                                         + _attachment.FileName);
                }
            }
 
            Id = strMsgID;  
 }
 
More information on Outlook.Inspectors can be found at this link.[^]

License

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

About the Author

Md. Marufuzzaman
CEO
Bangladesh Bangladesh
Member
He is the founder & CEO of MNH Technologies and working for urban and rural sectors to improve people’s lifestyle, better medical facilities, education, social business etc. He has over ten years of professional experiences in design and developing Client-Server, Multi-Tier, Database, Web based business software solutions, Enterprise Applications, API, WebAPI, Google Analytics implementation, Add-In, Documentation & Technical Writing etc for Windows / Mac using Microsoft SQL Server, Oracle, MySql, PS, C#, VB.NET, ASP.NET, PHP, RoR, Visual Basic etc. He has also more than two years experience in Mobile-VAS (Platform Development).
 
He worked for various software development & technology consulting. His core focus on technologies to create dynamic data-driven systems that add value to your business and dynamic technology consulting that builds advanced solutions for the industries across the various vertices.
 
He also work as a Solution Architect at Dhrupadi Techno Consortium Limited (DTCL) and responsible for analyzing business requirements and offered optimum solutions (multiple options), which would address all current requirements, provide flexibility for future growth and allow smooth transition between old system and new system.
 
He graduated with honors from The University of Asia Pacific, in Computer Science and Engineering. He was awarded as “Most Valuable Professional” (MVP) at 2010 and 2011 by CodeProject.com and also selected as a Mentor of CodeProject.com
 
Specialties: Software Development Management, System Integration, Data Warehouse Architecture, Virtualization.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralReason for my vote of 5 Helped me to start working on AddIn ...membershijis27 Oct '11 - 5:52 
GeneralSome help here for a VB.net programmermemberMichael Clinton26 Jan '10 - 11:57 
Does ThisAddin_startup code go in the Form1_Load sub?
What I did was create a ribbon with a button that opens a form. I then ask for a user id or lastname where I display a datagridview on result and then have them click on a row that gives me a Person ID. I hide the panel and then show another panel with more detail of that person. I want to then have the option to save the email body with a select of type of email... like Drug Screening, Back Ground Investication, ect... Then I want an option to save individual attachments again with attachment types. I would assume I would have a datagrid that would email body and this list off the individual attachments with a combobox column to save the files individual.
 
Any suggestions.
mjc
GeneralRe: Some help here for a VB.net programmermvpMd. Marufuzzaman26 Jan '10 - 18:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 24 Apr 2010
Article Copyright 2010 by Md. Marufuzzaman
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid