2016-06-21 72 views

回答

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); 
+0

非常感谢!如果这对我有用,我会让你知道.. :) – priyeshwagh777