Sync Outlook mail in .NET CRM application

I am developing a CRM application which follows the typical Company > Contact system.

Every Client's contact have email addresses stored.

Now, users send emails to contacts via Outlook(sometimes Exchange server or sometimes just as a mail client for google Apps...)

What I want to be able to do is to track all these emails within the CRM.

For example when users are browsing client records, they should be able to see all the emails sent/received between users in the company and clients.

What are my options?

From my limited knowledge I am guessing that when a user is logged on I query the user's mailbox and save mails to database.

I am not sure whether to use MAPI or System.Net.Mail.

Any suggestions, links etc would be highly appreciated.
Who is Participating?
DavidT543Connect With a Mentor Commented:
If you look at how HighRise do their CRM- they have an email address which you can use to bcc mails that get sent and received if you want them to add to the system. Would that work for you?
I have written such a CRM system.

I use MAPI and Redemption to access the emails.

You need to monitor the sent items and inbox for new and existing messages.
Each message you look at the recipients collection and for each recipient you extract the email address.

You can either do this as an Outlook addin - or you can log on directly to the exchange server via MAPI or web services and query the users maillbox from there. The former is easier to set up as permissions are all in place. THe latter requires you to use an account with permissions like Balckberry server (BIS) to access all the mailboxes.
isaackhaziAuthor Commented:
I would want to implement the first system as sometimes the mail server is not exchange and it could at times be Google Apps, so I would prefer to read emails from outlook rather than from the server.

So, once we get emails from the users outlook mail store, should I save the msg to disk and store it in the database. Is that the right way to do it?
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

isaackhaziAuthor Commented:
I would be greatful if you Could you provide me some code samples or links that would help me get started as I have never worked with MAPI objects or redemption before.

There are lots of ways to do this. A lot depends on how you want to display the information to users.

I would read the message body and store that. It could be in plain text - or in HTML so you will need to review that.

What database are you going to use? How will users access the database?

If you want to see how I implemented it - you can look at
You are on a very steep learning curve with Outlook and MAPI.

I suggest you start with the Outlook Code web site. It has lots of code samples.

There are two books which i have found invaluable:

Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators
by Sue Mosher

Professional Outlook 2007 Programming
by Ken Slovak
The redemption software provides ways to do stuff you can't do in the Outlook object model - and at much faster speeds.

DavidT543Connect With a Mentor Commented:
by the way with redemption its the RDO family of objects you want to work with. They will give you access to folders, item collections, emails, email body, recipient collections etc
isaackhaziAuthor Commented:
Ideally I would want to save the entire message msg format into database.
I am using SQl server 2008 R2.

It is a recruitment CRM system that tracks applicants and this will be one part/feature of this applicant tracking system where emails sent/received to applicants or clients will be tracked and stored in the database.

Users will see all messages associated with the applicant or client when they view the applicant /client profile ....

This is the idea....
isaackhaziAuthor Commented:
I have checked your implementation and it seems you have integrated the CRM into Outlook.

All I need is to save message files from inbox/sent items to database.

These messages will be displayed (in a simple grid) in the CRm application which is a standalone app.

on clicking the message I will write the msg file to disk and open it in the default mail client(Outlook).

isaackhaziAuthor Commented:
I guess it would be best for me to see if my approach is right. I guess you would be the best person to advice me.

I have a table with all Applicants (50k)
I have another table with contacts(2-3K)

When a user logins into the CRM.
I authenticate based on the default mail profile on the system.
Search the Inbox/Sent items to see if to/from address matches the emails in my 2 tables mentioned above...

If it does write message to file and save to database,...

This way all user mail will be saved to DB and can be viewed by all users..

Is this approach correct?
DavidT543Connect With a Mentor Commented:
There is not one approach that is 'correct'. Your method sounds like it will work.
All Courses

From novice to tech pro — start learning today.