salesforce 外部系统restful api方式集成sf邮件

2024-09-06 11:33:30 浏览数 (1)

本文记录外部系统restful api方式 集成sf邮件系统

代码语言:txt复制
                EmailMessage objEmail = new EmailMessage();
                objEmail.guid__c = RepostReq.EmailId;
                //email from address value
                objEmail.FromAddress = repostReq.fromAddress;
                //email from name value
                objEmail.FromName = repostReq.fromName;
                //email text body value
                objEmail.TextBody = repostReq.plainTextBody;
                //email html body value
                //objEmail.htmlBody = repostReq.htmlBody;
                //email subject value
                objEmail.Subject = repostReq.Subject;
                objEmail.RelatedToId = repostReq.recordidList[0];
                objEmail.status = '1';
                insert objEmail;


                for (Id RelationId : RelationIdList) {
                    EmailMessageRelation emlR = new EmailmessageRelation(EmailMessageId = objEmail.Id, 
                    RelationId = RelationId, // lead Id with a correctly formatted email address
                    RelationType = 'ToAddress');
                    insert emlR;
                }

需要注意的是:

  1. RelatedToId 能关联多种对象,但只能关联一个
  2. EmailMessageRelation中间表也可以关联对象,可以关联多个。只能关联contact 和lead 。
  3. EmailMessage对象insert后,登陆人为收件人时,可对邮件进行回复操作
  4. 邮件附件,待补充。

0 人点赞