盘点Salesforce Email Service相关问题

阅读: 评论:0

盘点Salesforce Email Service相关问题

盘点Salesforce Email Service相关问题

Outbound Email Service】:

8【Send Email Action Considerations for Cases】:Ref

7、【Email Author VS Composer】:
Email Author
访问链接:
组件特点:Classic产物,标准发送Single Email组件,可通过Sobject的Open Activities的Send Email访问,可选择From Address(自己 / OWA),支持邮件模板,发送邮件不计限制;
系统截图:

Composer
组件特点:LEX标准Send Single Email组件,存在于每个对象的Activity面板,支持合并字段,邮件模板。效果预览,不触发每日限制;
系统截图:

6、【如何查看系统日限制】:以SingleEmail为例:
方法1:使用Salesforce Inspector Chrome浏览器插件查看:

方法2:使用Workbench查看 - 下图找到SingleEmail即可查看;

5、【Apex Email Template与Email每日5000限制】:Email Limits
关于apex email是否计算daily limit of 5000 per org:
a. iggerUserEmail = true;创建Task发送Email Notification不计算限制;
b. send single email的toAddress为userid不计算限制,其他类型(conid, leadid, real internal and external user email address)计算限制;
c. send email with template,仅当setTargetObjectId为UserId不计算限制;

public class IMS_EmailUtil {public static final Id ORGWIDEEMAILADDRESSID = [SELECT Id, DisplayName, AddressFROM OrgWideEmailAddressWHERE DisplayName = 'Mysales' LIMIT 1].Id;public static final Map<String, String> EMAILTEMPLATE = new Map<String, String> {'[Automated Task]: Lead converted to Contact'                   => 'Hi: {0},nn'+'{1} has assigned you the following new task:nn'+'Subject: {2}n'+'Contact: {3}n'+'Priority: {4}n'+'Comments: {5}nn'+'For more details, click the following link:nn'+Label.DST_Community+'/{6}nn'+'Thank You','[Automated Task]: Please follow up the client assigned to you' => 'Hi: {0},nn'+'{1} has assigned you the following new task:nn'+'Subject: {2}n'+'Contact: {3}n'+'Client: {7}n'+'Priority: {4}n'+'Comments: {5}nn'+'For more details, click the following link:nn'+Label.DST_Community+'/{6}nn'+'Thank You','[Automated Task]: {0} Premium Payment Due Alert ({1} days)'    => 'Hi: {0},nn'+'System has assigned you the following new task:nn'+'Subject: {1}n'+'Contact: {2}n'+'Policy: {3}n'+'Due Date: {4}n'+'Priority: {5}nn'+'For more details, click the following link:nn'+Label.DST_Community+'/{6}nn'+'Thank You'};// this method won't count daily limit.public static void sendMassEmail(List<Task> newTasks) {Database.DMLOptions notifyOption = new Database.DMLOptions();iggerUserEmail = true;//we need to use the Database.insert() with the DMLOptions to insert the task instead of using the standard insert DML commandDatabase.insert(newTasks, notifyOption);}public static void sendTemplateEmail(String templateId, String targetObjId, String whatId) {Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();mail.setCharset('UTF-8');  // 支持繁体中文mail.setTemplateId(templateId);// The ID of the contact, lead, or user to which the email will be sent and ensures that merge fields in the template contain the correct data.mail.setTargetObjectId(targetObjId);// 仅当指定userid不计限制// If you specify a contact for the targetObjectId field, you can specify an optional whatId as well.if(String.isNotEmpty(whatId)) mail.setWhatId(whatId);mail.setorgWideEmailAddressId(ORGWIDEEMAILADDRESSID);Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });}// generate an email message// recipientId are user ids / contact idspublic static Messaging.SingleEmailMessage generateEmailMsg(List<Id> recipientId, String subject, String body){Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();email.setCharset('UTF-8');  // 支持繁体中文email.setSaveAsActivity(false);// email.setOrgWideEmailAddressId(Label.OrgWideEmailId);email.setOrgWideEmailAddressId(ORGWIDEEMAILADDRESSID);// if the recipientId is user, system won't count towards daily limit(no need to set setTargetObjectId with user id), but ail.setToAddresses(recipientId);email.setSubject(subject);email.setPlainTextBody(body);return email;}// generate an email message// emailAddrs are email address listpublic static Messaging.SingleEmailMessage generateEmailMsg(List<String> emailAddrs, String subject, String body){Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();email.setCharset('UTF-8');email.setSaveAsActivity(false);// email.setOrgWideEmailAddressId(Label.OrgWideEmailId);email.setOrgWideEmailAddressId(ORGWIDEEMAILADDRESSID);// even though the addresses are internal user's email including portal user, system will still count towards ail.setToAddresses(emailAddrs);email.setSubject(subject);email.setPlainTextBody(body);return email;}// log email errorpublic static void logEmailError(Messaging.SendEmailResult[] results){Messaging.SendEmailError[] errors = new Messaging.SendEmailError[]{};String emailError = '';for(Messaging.SendEmailResult result : results)if(!result.success)emailError += (s[0].message + 'n');// save error logsif(String.isNotEmpty(emailError)) IMS_2019LoyaltyCampaign.saveErrorLog('IMS_EmailUtil', emailError.left(255), 'Messaging.SendEmailResult', 'SingleEmailMessage[]');}
}

4、【Email Footers】:
基础知识:系统级别(直接应用在Salesforce所有类型是Outbound Email中,如作用在Email Template和Apex Email Alert的Email后),可通过Email Encoding来决定应用哪一种Email Footer;
系统截图:

案例分析:假如同一个Org共存2家公司(母子公司关系),在2家公司有各自的品牌化前提下,分析Email Footer如何作用于2个Group?
我们知道Email Footer由Email Encoding决定,那么sf中大概有这些地方可以控制Email Encoding:
a. Email Template的Encoding,又分系统Email(By default, the character encoding is for western languages[General US & Western Europe (ISO-8859-1, ISO-LATIN-1)].)和Custom Email Template(可控制);

测试重置密码系统Email Template时,发现不能将其deactivate掉,同时,即便Email Encoding为UTF-8也不会携带Email Footer.

b. User Record Email Encoding;

c. Send Email From Apex -> email.setCharset('UTF-8'),If this value is null, the user's default value is used.

总结Email Template(含模板) > Apex setCharset(不含模板) > User Record Encoding

发送邮件类型Email Footer决定因素是否触发Email每日5000限制其他
System Email系统邮件默认Encoding为ISO-8859-1,Email Footer只要使用其他常见编码即可避开Email Footer影响无限制一般由xxx@salesforce发送,如Apex Exception Email,如Change / Reset Passowrd Email for Internal User
Email Author / Composer

在Email Author/Composer中手动插入邮件模板由模板Encoding决定
以下由User Record决定
a. 未指定模板;
b. Case Send Email Action中指定Default Email Template;
c. 实现QuickActionDefaultsHandler并指定邮件模板(Setup -> Support Settings -> Enable Default Email Templates or the Default Handler for Email Action -> Apex Class Name);

b, c同时存在,c覆盖b
Default Email Template set up for the Email quick action

无限制

<Developer版本日限制10>

Single emails sent using the email author or composer in Salesforce don't count toward this limit. There’s no limit on sending single emails to contacts, leads, person accounts, and users in your org directly from account, contact, lead, opportunity, case, campaign, or custom object pages.
The Send Email action isn’t available in Communities.
From Address: Context User / OWA(可选)
Apex Email form Task Creation仅与Sender User Record有关,若未匹配,则无Footer无限制缺点:使用iggerUserEmail = true发送Email,Task Status必须设为未完成的任一状态,且Email中Task链接Domain为Classic(LEX适用),对Portal User不友好
From Address: Context User
Apex Email with TemplateEmail Footer仅与Template的Encoding有关,不受User和Apex Email的setCharset对应的Encoding影响;Apex: 仅当setTargetObjectId参数为 userid无限制
Apex Email without TemplatesetCharset in Apex > Sender's User Record仅当setToAddresses参数为UserIds无限制,LeadIds / ContactIds以及Internal User的Email Addresses都会触发限制From Address: Context User
Change Owner with "Send Email Notification" checked in both Salesforce and CommunityNew Owner is a User: 由新Owner的User Record Email Encoding决定;
New Owner is a Queue
Footer默认为UTF-8
a. 当#1有值 #2未勾选 => 只通知#1;
b. 当#1有值 #2勾选 => 通知#1和所有members;
c. 当#1无值,不管#2是否勾选,只通知所有members; 
无限制用例:Lead Change Owner勾选send email notification触发邮件;
From Address
New Owner is a User: Community中,sender为Administration的Emails配置,修改Email需新Email验证;SF中sender为context user;
New Owner is a Queue: sender为context user;

(Ref: Queue)


(Ref: Support Settings)


(Ref: Case Action)

3、【Partner Community Email From Address设置】:重置密码,忘记密码及Change Record Owner等Email Notification
Community -> Workspaces -> Administration -> Emails -> Sender

2、【使用自定义Email Template】:String formattedText = String.format(template, args);

trigger Trigger_Task_Send_Email on Task (before update) {Set<Id> ownerIds = new Set<Id>();for(Task tsk: Trigger.New)ownerIds.add(tsk.ownerId);Map<Id, User> userMap = new Map<Id,User>([select Name, Email from User where Id in :ownerIds]);for(Task tsk : Trigger.New) {User taskOwner = (tsk.ownerId);String[] toAddresses = new String[] {taskOwner.Email};Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();mail.setToAddresses(toAddresses);    mail.setSubject('A task owned by you has been updated');String template = '{0}, has updated the following new task:- nn';template+= 'Subject - {1}n';template+= 'Status - {2}n';template+= 'Priority - {3}n';List<String> args = new List<String>();args.add(tsk.LastModifiedBy.name);args.add(tsk.Subject);args.add(tsk.Status);args.add(tsk.Priority);String formattedText = String.format(template, args);mail.setPlainTextBody(formattedText);Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});}
}

1、【Salesforce标准的Mass Email Users使用注意事项】:
用例:每逢小长假,Admin可以通过该功能为Active的Internal User发送放假通知;
注意事项:在UAT测试该功能时,比如从Active User List View选择2个做发送测试,首页在table header部分取勾重选2个,仅表示当前分页取勾,如果有下一页,下页部分的所有项均默认勾上,需要每页取勾。

Inbound Email Service】:

1、【Email-to-Case要点】:
a、Email Address VS Email Services Address in Email-to-Case Settings | Ref
想让Inbound Email在SF中创建Case,必须配置启用Email-to-Case并搭建Routing Addresses,键入公司Email Address后,我们发现SF自动生成了Email Service Address,要想Inbound Email创建Case,客户必须Send Email To/CC/BCC Email Service Address,当然如果想让客户Send Email To/CC/BCC Email Address也能创建Case,那么需要在公司Mail Service配置将发送到Email Address的Email转给Email Service Address。简而言之,Inbound Email创建Case的关键是要经过SF根据公司Email Address生成的Email Service Address;

Define email addresses on your email system for case submissions. Create email routing addresses that include the addresses defined for cases. Configure your email system to forward case submissions to the Email Services Address provided to you by Salesforce.

As best practice, set up different emailAddresses for your sandbox(es) and PROD - each will have a different EmailServicesAddress - this will let you test this setup before rolling out to PROD. Hence your mailsystem admin will have to configure multiple rules -- like mysandbox-support@mycompany forwards to the sandbox's emailservices address whereas support@mycompany forwards to the PROD email services address

本文发布于:2024-02-03 02:10:04,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170689740447944.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:Salesforce   Email   Service
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23