I work for an organisation that provides IT services to many different and separate organisations. Some of these organisations use MS Exchange and some use IBM Domino for mail infrastructure. I have recently had to write an “inbox aware” .net application that can read and process inbox data, but I needed to do this independently of the underlying mail infrastructure, as it needed to run for all organisations.
I thought about simply using POP3 for this, but this has some limitations.
- It isn’t running by default on any of the Domino or Exchange Servers.
- It doesn’t support rich text.
- It doesn’t support custom fields.
- It usually isn’t allowed through firewalls.
Custom field support was quite important because many of Domino mailboxes have custom fields that we may need to process via our .net application.
I have created a small sample application demonstrating how I went about this. I implemented a small IMailConnector interface in .Net and then created two MailConnector Classes that matched this interface. The ExchangeMailConnector class uses WEBDAV (over http obviously) to read and process mail in an exchange mailbox. The DominoMailConnector connects to an agent in the mailbox over http and processes xml/html and binary data supplied by that agent. The agent is my own creation ( yes, I program in Lotusscript as well ) and needs to be placed in the design of the Domino mailbox database for the DominoMailConnector to work.
If you are going to test this sample, please do it on test mailboxes as the default behaviour of the connector classes is: read e-mails, place the data in SQL and then DELETE the original message. So don’t blame me if you runs this app and then your mailbox is empty, you have been warned. The reason for this behaviour is because the easiest way to make sure you only process a message once is to delete it after you have processed it. If you require a different behaviour then you will have to write your own code to determine if you have or haven’t processed an e-mail already.
The zipped vs C# 2005 sample application is
here. It provides the following features:
- Connections to both an Exchange or Lotus Notes/Domino Mail box
- Retrieves "from" , "subject","html message body" and attachments and embedded objects. (Fully Extendable)
- Stores the retrieved mailbox data in SQL for easy access from .Net
- Does not use POP, so is extendable to support custom fields in Both Domino & Exchange.
- Uses HTTP for connections so can be used through web-only firewalls.
To setup the sample app you need to do the following:
Create a blank SQL database on your SQL server and then run the DBSetup.SQL file in the DBSetup folder of the solution against it. This will set up the tables and the stored procs to handle the storage of the e-mail data given by the connectors.
Once you have done this then you will need to adjust the web.config of the solution so the connectionstring of the “mailboxconnection” matches your SQL setup.
You next need to adjust the web.config to match your mailbox setup. If you are using a Exchange Server then you will need to set the MailBoxType Key to “Exchange” and set the other keys to match your mailbox server,username and password.
If you are using a Domino Server then you will need to set the MailBoxType to “Domino” and set the other keys to match the domino server,mail database location,domino userid and password.
If you are using Domino you will also need to copy the (dotNetDataViewer.xml) agent ( Found in the HojuRetriever.nsf database in the Domino Folder of the solution ) into the mail database you will be accessing. The agent needs to run with at least Designer access.
Once you have done this then you should be able to run the solution, press the “Get Mail” button to retrieve messages from the mailbox.
If you need a better understanding of some of the “plumbing” of this application then please leave a comment and I will endeavour to answer your questions.
Good Luck !!
Pic of Message ViewLabels: C#, Code