Salesforce API: is it possible to create EmailMessage and link a contact?

I am working on a project in which (already sent) emails must be saved in Salesforce and mapped to the corresponding Salesforce contact.

Creating new letters is quite simple. For example, using the python simple_salesforce library, my code looks like this:

from simple_salesforce import Salesforce

[…]

sf = Salesforce(instance_url=instance_url, session_id=session_id)
sf.EmailMessage.create(
    {'FromAddress': 'foo@example.com',
     'ToAddress': 'bar@example.com',
     'Subject': 'Email: Fancy Subject', 
     'TextBody': 'lorem ipsum dolor sit amet',  
     'Status': 2
    })

This successfully creates a new EmailMessage, but the message does not match the contact (assuming bar@example.com is the current contact in Salesfored). This can be seen in many places in the Salesforce user interface. For instance:

  • This is not part of the contact history.
  • When viewing email details, the Sender and Recipients section is empty.

Salesforce . EmailMessage , Salesforce, : ActivityId .

ActivityId, INSUFFICIENT_ACCESS_OR_READONLY.

API?

+4

Source: https://habr.com/ru/post/1660497/


All Articles