我正在制作一个插件,该插件会在自定义活动短信的创建消息上触发。
这些插件将使用第三方短信服务提供商发送实际短信。
因此,我需要获取短信活动“收件人”字段中每个联系人的手机号码。这是一个类型为:PartyList 的字段。
我目前正在使用以下代码:
EntityCollection Recipients;
Entity entity = (Entity) context.InputParameters["Target"];
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
Content = entity.GetAttributeValue<String>("subject");
Recipients = entity.GetAttributeValue<EntityCollection>("to");
for (int i = 0; i < Recipients.Entities.Count; i++)
{
Entity ent= Recipients[i];
string number = ent["MobilePhone"].ToString();
}
但这不起作用,我认为 ent 变量不包含属性。
我也尝试过使用 ActivityParty 进行编码,但也不走运。
我希望你们中有人能帮助我解决这个问题。
Thanks!
Recipients
是一个列表ActivityParty http://msdn.microsoft.com/en-us/library/gg328549.aspx,而不是联系人、帐户……。
因此你必须阅读它的PartyId http://msdn.microsoft.com/en-us/library/gg328278.aspx#attribute
EntityReference partyId = ent.GetAttributeValue<EntityReference>("partyid");
有了这些信息,您必须查找与此 partyID 相关的记录。它可以是联系人、帐户、系统用户……
您将获得此信息
var partyType = partyId.LogicalName;
然后你可以检索该记录以读取该号码。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)