简体   繁体   English

如何通过使用C#代码在Microsoft Dynamics 365中附加注释中的图像(注)

[英]How to attach Image in Annotation(Note) in Microsoft Dynamics 365 By using C# code

if (note.FileName !=null)
    noteEntity.Attributes.Add("filename", (note.FileName));
if (note.DocumentBody != null)
    noteEntity.Attributes.Add("documentbody", Convert.ToBase64String(note.DocumentBody)); `

For This Code Using I will attach .txt and .doc file but I want to attach Image file on Note in Dynamics crm so How I attach image file ? 对于此代码使用,我将附加.txt和.doc文件,但我想在Dynamics crm中的“注释”上附加图像文件,因此如何附加图像文件?

You can create an attachment like so, the process is the same for all file formats. 您可以像这样创建附件,所有文件格式的过程都相同。 To have your file treated as an image, you need to provide the media type via the mimetype . 要将文件视为图像,您需要通过mimetype提供媒体类型

void AttachDocument(ICrmService service, Guid entityId, String entityType, String path, String mimeType)
{
    String fileName = Path.GetFileName(path); //load the attachment file from disk

    annotation a = new annotation(); //we have to create an annotation

    a.objectid = new Lookup(entityType, entityId); //and attach to a record, e.g. contact
    a.objecttypecode = new EntityNameReference(entityType);

    a.subject = fileName;

    a.filename = fileName; //the annotation has fields which contain the attachment information
    a.mimetype = mimeType;
    a.documentbody = Convert.ToBase64String(File.ReadAllBytes(path)); //crm like us to store attachments as base64 strings

    service.Create(a);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Microsoft Dynamics 365 CRM 身份验证的示例代码,然后重定向到 C# 控制台应用程序 - sample code for Microsoft Dynamics 365 CRM authentication and then redirect to C# console application 无法使用 C# 中的“Microsoft.CrmSdk.XrmTooling.CoreAssembly”连接 Dynamics 365 统一接口 - Not able to connect Dynamics 365 Unified Interface by using "Microsoft.CrmSdk.XrmTooling.CoreAssembly" in C# c# OdataClient:DataServiceActionQuery,如何执行Microsoft Dynamics 365 Business Central 的功能? - c# OdataClient: DataServiceActionQuery, how to execute a function Microsoft Dynamics 365 Business Central? 使用 C# 代码从 DYNAMICS 365 crm 检索/获取记录 - Retrieve/fetch records from DYNAMICS 365 crm using C# code 如何 go 关于它:从 Microsoft Dynamics 365 CRM 同步/导出帐户数据并在第 3 方 web 应用程序中显示? 使用 WS 和 ASP.NET MVC/C# - How to go about it: sync/export data for Accounts from Microsoft Dynamics 365 CRM and show it in a 3rd party web app? Using WS and ASP.NET MVC/C# 使用 Kingswaysoft 将注释上传到 Dynamics 365 - Upload annotation into Dynamics 365 using Kingswaysoft 如何使用C#将多重身份验证登录到Dynamics 365 - How to login Multi-Factor Authentication to Dynamics 365 using C# 如何格式化Dynamics 365 C#插件的LINQ查询 - How to format LINQ query for Dynamics 365 c# plugin 我可以在.NET / C#中为Microsoft Dynamics AX进行编码吗? - Can I code in .NET/C# for Microsoft Dynamics AX? 是否可以使用c#更改Microsoft Dynamics导航页的属性? - Is it possible to change the properties of a Microsoft Dynamics NAV page using c#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM