本文记录外部系统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;
}
需要注意的是:
- RelatedToId 能关联多种对象,但只能关联一个
- EmailMessageRelation中间表也可以关联对象,可以关联多个。只能关联contact 和lead 。
- EmailMessage对象insert后,登陆人为收件人时,可对邮件进行回复操作
- 邮件附件,待补充。
。