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.[
^]
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.