Import Email Messages in bulk and relate them to Contacts + Display on Activity Timeline
4:09 PMFound this article on the Salesforce Knowledge base. However, this method does not work and not sure if the article is even accurate. The last part of the article asks to perform a Update on the 'EmailRelation' object but without a Id field mapped, so i believe the article needs to be checked for accuracy.
The steps below are the ones that worked for me and happy to share it here. Before looking at the steps, some points to note about uploading Email Messages via the data loader.
- The Email Message object has a Status field. This is set to '5' (Draft) by default. The record is only update-able as long as it is in Draft status.
- Uploading to this object will not send out an actual email.
- If the uploading CSV file has a single error, all records fail in the operation. I experienced this for the EmailMessage object and the EmailRelation object. One of the records in the relation object pointed to a merged contact and my entire file failed with the same error for all rows. On removing that particular record, the file uploaded successfully.
STEP 1:
Prepare a CSV file with the following headings. Note that the Status column has to be set to '3' , the value 3 denotes Sent. Not all fields are mandatory, at a minimum make sure at least From Address, To Address, HTML Body / Text body, Status, Message Date are filled in.
- From Address
- From Name
- To Address
- CC Address
- BCC Address
- Is Incoming
- Message Date
- Status (Should be set to '3')
- Headers
- Subject
- Text Body
- HTML Body
STEP 2:
Upload the CSV file prepared in Step 1 using the data loader.
- Operation - Insert
- Object - 'Show All objects' selected and choose 'Email Message (EmailMessage)'
- Auto Match fields to columns and Confirm insert
STEP 3:
Prepare a CSV file with the following columns
- Email Message ID (This ID is got from the success log files generated in Step 2 above)
- RelationId (the record Id of a contact, user or lead)
- RelationType (this can be either FromAddress or ToAddress, if you want to do both repeat step 3 twice)
STEP 4:
Upload the file prepared in Step 3 using the data loader
- Operation - Insert
- Object - 'Show All objects' selected and choose 'Email Message Relation (EmailMessageRelation)'
- Auto Match fields to columns and Confirm insert
- Note: If you run into errors change the batch size to 1 under data loader settings and try again.
1 comments
Awesome
ReplyDelete