正在尝试从安装了CRM的服务器读取文件。当我从服务器读取文件时,插件抛出一个错误"Directory not found“。
Entity attachment = new Entity("activitymimeattachment");
FileStream stream = File.OpenRead(fileName);
byte[] byteData = new byte[stream.Length];
stream.Read(byteData, 0, byteData.Length);
stream.Close();
// Encode the data using base64.
string encodedData = System.Convert.ToBase64String(byteData);
attachment["subject"] = "Attachment";
attachment["filename"] = "emailstatement.pdf";
//byte[] fileStream = Encoding.ASCII.GetBytes(fileName);
attachment["body"] = encodedData;
attachment["mimetype"] = @"application\pdf";
attachment["attachmentnumber"] = 1;
attachment["objectid"] = new EntityReference("email", emailguid);
attachment["objecttypecode"] = "email";
service.Create(attachment);有没有人可以帮我用插件从服务器上读取文件?
谢谢。
发布于 2019-04-28 04:28:14
确保您的插件是在沙箱之外注册的(部分信任)。这是插件注册工具中的一个选项。
Plug-in isolation, trusts, and statistics
Microsoft Dynamics 365 (在线和本地)支持在隔离环境中执行插件和自定义工作流活动。在此隔离环境中,也称为沙箱,插件或自定义活动可以利用Microsoft Dynamics 365 SDK的全部功能来访问组织web服务。沙箱中会阻止对文件系统、系统事件日志、某些网络协议、注册表和更多的访问。
https://stackoverflow.com/questions/55850839
复制相似问题