我有一个要求,我需要将SharePoint中的文档添加到Dynamics CRM Workflow,我可以在其中发送电子邮件。
这可以实现吗?此外,有没有解决方法,我可以完成这项工作? 好心提醒。谢谢!
答案 0 :(得分:0)
您想要实现的目标无法开箱即用,但您可以做的是,创建自定义工作流活动并以编程方式从SharePoint读取文件,并将字节数组作为base64字符串写入活动主体,创建一封电子邮件,并将该文件作为附件附加到电子邮件中,然后将其发送出去。
var email = new Email
{
Subject = "Email with attachment from SharePoint.",
Description = "Find the document attached.",
From =
new[]
{
new ActivityParty() { PartyId = new CrmEntityReference(SystemUser.EntityLogicalName, fromUserGuid) }
},
To =
new[]
{
new ActivityParty() { PartyId = new CrmEntityReference(SystemUser.EntityLogicalName, toUserGuid) }
},
DirectionCode = true
};
var emailId = organizationService.Create(email);
var sampleAttachment = new ActivityMimeAttachment()
{
ObjectId = new CrmEntityReference(Email.EntityLogicalName, emailId),
ObjectTypeCode = Email.EntityLogicalName,
Subject = "File attached from sharepoint",
Body = Convert.ToBase64String(new byte[] { }), //replace the bytes with the file bytes read from SharePoint
FileName = "sharepointattachment.txt"
};
organizationService.Create(sampleAttachment);
var sendEmailMessageRequest = new SendEmailRequest() { EmailId = emailId, IssueSend = true };
var sendEmailResponse = (SendEmailResponse)organizationService.Execute(sendEmailMessageRequest);