csharp CRM 2016 #Emails#C#CRM2016 #MoussaElAnnan
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp CRM 2016 #Emails#C#CRM2016 #MoussaElAnnan相关的知识,希望对你有一定的参考价值。
/// <summary>
/// Function that gets the notes attachments and create them in the email created in the workflow created email.
/// </summary>
/// <param name="service">The organization service.</param>
/// <param name="iaaTaskEntity">The iaa task entity.</param>
/// <param name="targetEmailID">The target email id.</param>
/// /// <param name="tracingService">The tracing service.</param>
public static void GetNotesAttachmentAndAddThemToTheEmail(IOrganizationService service, Guid entityId, EntityReference targetEmailID, ITracingService tracingService)
{
//Get email details
Entity resultEntity = service.Retrieve("email", targetEmailID.Id, new ColumnSet(true));
var _QueryNotes = new QueryExpression("annotation");
_QueryNotes.ColumnSet = new ColumnSet(new string[] { "subject", "mimetype", "filename", "documentbody" });
_QueryNotes.Criteria = new FilterExpression();
_QueryNotes.Criteria.FilterOperator = LogicalOperator.And;
_QueryNotes.Criteria.AddCondition(new ConditionExpression("objectid", ConditionOperator.Equal, entityId));
EntityCollection mimeCollection = service.RetrieveMultiple(_QueryNotes);
if (mimeCollection.Entities.Any())
{
foreach (var noteAttachment in mimeCollection.Entities)
{
//Entity _NotesAttachment = mimeCollection.Entities.First();
//Create email attachment
Entity emailAttachment = new Entity("activitymimeattachment");
if (noteAttachment.Contains("subject"))
{
emailAttachment["subject"] = noteAttachment.GetAttributeValue<string>("subject");
tracingService.Trace("Tracing: Subject: " + emailAttachment["subject"]);
}
emailAttachment["objectid"] = new EntityReference("email", resultEntity.Id);
emailAttachment["objecttypecode"] = "email";
if (noteAttachment.Contains("filename"))
{
emailAttachment["filename"] = noteAttachment.GetAttributeValue<string>("filename");
tracingService.Trace("Tracing: FileName: " + emailAttachment["filename"]);
}
if (noteAttachment.Contains("documentbody"))
{
emailAttachment["body"] = noteAttachment.GetAttributeValue<string>("documentbody");
tracingService.Trace("Tracing: Body: " + emailAttachment["body"]);
}
if (noteAttachment.Contains("mimetype"))
{
emailAttachment["mimetype"] = noteAttachment.GetAttributeValue<string>("mimetype");
tracingService.Trace("Tracing: MimeType: " + emailAttachment["mimetype"]);
}
service.Create(emailAttachment);
}
}
以上是关于csharp CRM 2016 #Emails#C#CRM2016 #MoussaElAnnan的主要内容,如果未能解决你的问题,请参考以下文章
csharp CRM 2015-2016 C#Helper #Teams #Sharing#CRM2016 #MoussaElAnnan
csharp CRM 2016 C ## C ##OptionSets #MoussaElAnnan
csharp CRM 2016 #Workflows#CRM2016 #MoussaElAnnan
csharp CRM 2016 #UnitTests#CRM2016 #MoussaElAnnan
csharp CRM 2016 #Client #Connection #CrmServiceClient#CRM2016 #MoussaElAnnan
dynamic2016 crm 安装语言包提示缺少组件报错