When migrating from Goldmine and some other CRM systems to MS CRM there is sometimes a need to import historical email. This is frequently stored in a SQL database in rfc822 format. RFC822 is an email format standard.
What I am providing is a single class along with a file from the MS CRM SDK that this class currently uses. This single class is consolidated from a number of other classes in my import framework and is intended to give you a nearly complete rfc822 import solution that you can modify for your needs. Every place that you need to make a modification according to your particular system has a //TODO: comment explaining what you need to adjust particular to your configuration. In addition assume that there will be some tweaking required, and make sure to do thorough debugging and testing to verify that your email records are being properly generated.
You can download the source code here.
There are 2 steps to using this class.
Part 1: Initialize a new RFC822ToEmailActivity object.
Part 2: Calling the CreateEmailFromRfc822Record() method
CreateEmailFromRfc822Record() should be called in your loop that is reading the rfc822 records
- Calls parsing method
- Creates email attachments from pathnames returned from parsing method.
- Writes to an error log file with all attachments that are not found and other errors.
- Makes any other changes to the email entity before saving it.
- Sets Email State as completed (sent or received) based on local domain name.
Called Internally: ParseRFC822() parsing and email activity creation.
- Parse an rfc822 record
- Create an email activity based on that record.
- Compare email addresses, both To: and From: with a local domain name to decide if the email is incoming or outgoing.
- Create ActivityParties for To:, CC:, BCC:, From: related to CRM users, Contacts, Accounts and Leads in that match order precedence.
- Return a list of pathnames to any attachments.
RFC882 Email Attachments
Products like Gold Mine are storing email bodies in the database but they only have pathnames to the attachments. These attachment paths are frequently on the end user’s local computer which can be unreliable. These attachments may have been renamed, moved or deleted.
Hint1: Create a single shared folder on a file server with a separate tree branch for each computer that has attached files in the email history and modify the pathnames programmatically to match the structure you create on the file server.
S:\importattachments\C\Documents and Settings\mkovalcson\My Documents
Hint2: Comment out or create a test mode where nothing is written into the CRM database, but missing attachments are still written to a log file where you can see what isn’t found and decide how important it is to hunt attachments down before the final import.
You may want to look at this before you get started.
MS CRM Data Import (Cleaning up the Mess)