在Dynamics CRM插件中访问电子邮件发件人的地址 [英] Accessing email sender's address in dynamics CRM plugin
问题描述
我正在编写一个Dynamics CRM 2011插件,该插件挂接到电子邮件实体的更新后事件(
I am writing a Dynamics CRM 2011 plugin that hooks into the Email entity's post-update event (stage 40 of the pipeline), and am having trouble accessing the From address of the email at this stage in code.
我们已经建立了一个电子邮件路由器,可以将发送到特定地址的电子邮件转发到Dynamics CRM.它们最终以电子邮件实体的形式出现在服务队列中.当我在前端打开这些记录时,发件人地址可见(并链接到相关的用户/联系人,如果适用).
We have set up an email router that forwards on emails sent to a specific address to Dynamics CRM. They end up in the service queue as Email entities. When I open those records in the frontend, the From address is visible (and linked to the relevant user/contact if applicable).
但是,如果我尝试使用代码访问电子邮件实体的From属性,则该属性为null.示例:
However, if I attempt to access the From property of the email entity in code, it is null. Example:
protected void ExecutePostEmailUpdate(LocalPluginContext localContext)
{
if (localContext == null)
{
throw new ArgumentNullException("localContext");
}
var entity = (Entity)localContext.PluginExecutionContext.InputParameters["Target"];
var email = entity.ToEntity<Email>();
var from = email.From != null ? email.From.First().Id.ToString() : "[null]";
this.Log("Email from: {0}", from);
}
在所有情况下,我的日志中都会显示来自:[null]的电子邮件".
In all cases, I get "Email from: [null]" in my log.
有人有什么建议吗?有必要对相关事件进行处理(如果是通过电子邮件创建的),为此,我需要查看电子邮件的来源.
Does anyone have any suggestions? There is a requirement to do something to the related incident (if one is created from the email) and for this, I need to see who the email was from.
谢谢.
推荐答案
如果这是更新后的消息,并且 from address 字段在更新过程中未更改,则不会传递给 Target 参数.您需要添加前后图像,并向该图像添加 from address 属性.这样您就可以从图片中获取价值
If this is post-update and from address field hasn't changed during update, it will not be passed to plugin in Target parameter. You need to add pre/post image and add from address property to this image. Then you'll be able to get value from image
这篇关于在Dynamics CRM插件中访问电子邮件发件人的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!