Access your Email within Outlook - Part One of Three
Introduction
This is an introduction to Microsoft Outlook and its accessible properties and methods you can access through C#. We will not be working with the entire set of properties and methods, just the properties that can be attributed to an email. We will be showing you how to access your Outlook email through C# and how to display that information on a screen
We are using Server Intellect and have found that by far, they are the most friendly, responsive, and knowledgeable support team we've ever dealt with!
Implementation
In this article we will be working with Microsoft Outlook and its accessible properties and methods. We will be inserting a reference to the Outlook Namespace and accessing the Inbox to see if we can locate an email. If we find an email we will then go ahead and display the first email we find, and even display the name of the first attachment in that email.
Here are the properties that we will be working with in this example:
- Subject
- Body
- Attachment Name
- Sender Name
- Sender Email Address
- Email creation Date
Prerequisites
Development Environment
Before you can start using the Outlook Properties in this example we have to make sure that you have a reference to the Outlook file.
If you are using Outlook/Office 2003 or Outlook/Office 2007, you should run the office install and choose .NET Programmability Support for version 2.0. For Office XP, you can download the necessary files from here.
To change the Office features and settings you need to go to the “Control Panel” and select “Uninstall or change a Program”. This will bring you to the following screen in Fig. 1.
Screen shot of Uninstall or change a Program screen. Fig. 1
[Click to see full-size]
Yes, it is possible to find a good web host. Sometimes it takes a while. After trying several, we went with Server Intellect and have been very happy. They are the most professional, customer service friendly and technically knowledgeable host we've found so far.
You want to right mouse click on the Office entry and select the “Change” option. This will bring you to the following screen in Fig. 2.
Screen shot of the “Installation Options”. Fig. 2
[Click to see full-size]
If this option is not installed on your system you will need to install this option before continuing with any of the following steps, because they will not work until this feature has been installed.
The next step is to add a reference to the dynamic link library for Outlook which is called Microsoft.Office.Interop.Outlook.dll. Please refer to Fig. 3.
Screen shot of “References” in the solution. Fig. 3
[Click to see full-size]
We chose Server Intellect for its dedicated servers, for our web hosting. They have managed to handle virtually everything for us, from start to finish. And their customer service is stellar.
This is done by selecting “References” in your solution and right mouse clicking on it and selecting “Add a Reference”. At this point you will see the following screen as in Fig. 4.
Screen shot of “Add Reference” screen. Fig. 4
[Click to see full-size]
When you have selected the correct reference you select the “OK” button and this reference will be added to your project under references.
Next Up
You have now completed all of the prerequisites for this example. In the next article we will start to build the application to access your Outlook Email.
What have we learned?
We migrated our web sites to Server Intellect over one weekend and the setup was so smooth that we were up and running right away. They assisted us with everything we needed to do for all of our applications. With Server Intellect's help, we were able to avoid any headaches!
- How to change the Outlook Features needed for this example
- How to add the Outlook Reference to your Project
Attachments
|