【发布时间】:2015-12-28 20:27:22
【问题描述】:
我正在尝试创建在发送电子邮件时触发的插件。
起初我尝试使用 SetState 和 SetStateDynamicEntity 来将状态更改为完成。但是,当发送电子邮件时,插件永远不会被触发。
所以我尝试使用 OnExecute 方法使用“发送”消息。是否可以检索已发送的电子邮件实体信息?我很难尝试返回实体。下面的代码不断返回“字典中不存在给定的键”错误消息。
我尝试使用“Entity”或“EntityReference”,但没有成功。
我知道发送消息返回 EmailId。是从这个 EmailId 返回实体的唯一方法吗?
public override void OnExecute(IServiceProvider serviceProvider, IPluginExecutionContext context) { var trace = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
if (!context.InputParameters.Contains("EmailId"))
{
return;
}
var emailId = (Guid)context.InputParameters["EmailId"];
Entity emailEntity = (Entity)context.InputParameters["Target"];
【问题讨论】:
-
我只是使用检索来获取实体,但想知道是否有更直接的方法。实体 emailEntity = service.Retrieve("email", emailId, new ColumnSet(true));
-
嗨 ichachan - 你注册了哪个插件消息/步骤?我也在类似的船上。不确定是什么插件事件表明电子邮件已发送。