首页 > 其他分享 >D365: 邮件附件中文名乱码问题

D365: 邮件附件中文名乱码问题

时间:2022-08-19 15:34:41浏览次数:44  
标签:D365 邮件附件 SysMailerMessageBuilder System 乱码 using Net

在D365中,发送QQ,163,Foxmail邮箱如果附件名称中带中文名,收件箱的附件名称出现乱码解决方案

增加c# class library

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Mail;
using System.Net.Mime;

namespace VyaHandleEmailAttachments
{
    public class VyaHandleAttachment
    {
        public static void handleAttachment(AttachmentCollection _collection)
        {
            foreach (Attachment attachment in _collection)
            {
                ContentDisposition disposition = attachment.ContentDisposition;
                disposition.FileName = attachment.Name;
            }
        }
    }
}

 D365中,扩展Class: SysMailerMessageBuilder中的addAttachment方法

[ExtensionOf(classStr(SysMailerMessageBuilder))]
internal final class SysMailerMessageBuilderVya_Extension
{
    public SysMailerMessageBuilder addAttachment(System.IO.Stream _stream, str _name, str _contentType)
    {
        System.Net.Mail.MailMessage             mailMessage;
        System.Net.Mail.AttachmentCollection    attachmentCollection;
        ;
        SysMailerMessageBuilder builder = next addAttachment(_stream, _name, _contentType);
        mailMessage          = builder.getMessage();
        attachmentCollection = mailMessage.Attachments;
        
        VyaHandleEmailAttachments.VyaHandleAttachment::handleAttachment(attachmentCollection);
        
        return builder;
    }

}

  

 

标签:D365,邮件附件,SysMailerMessageBuilder,System,乱码,using,Net
From: https://www.cnblogs.com/dingkui/p/16602128.html

相关文章

  • 防止中文程序在英文系统上乱码
    uses Windows;在工程文件中添加一句代码,如下:Application.Initialize;//添加以下一句解决外文系统乱码问题SetThreadLocale(DWORD(Word(SORT_DEFAULT)shl16)or ......
  • C#交互窗口(C# Interactive)乱码的解决方法
    在单位内网工作机上的VS2019做开发时,有时会需要用到C#交互窗口,但是之前使用的时候,凡是需要显示中文的地方都会出现乱码(如提示警告错误等);特别是使用时出现了错误,但错误......
  • IntelliJ IDEA 2022解决控制台中文乱码
    1.打开设置单击Settings  2.在Editor下面FileEncodings中的projectencoding设置为GBK其他设置为UTF-8  3.在General下面的Console里DefaultEncoding更改为......
  • weblogic11g打补丁,应用出现乱码
    解决办法:1、找到域下的这个路径:autodeploy\manager\WEB-INF里的web.xml文件,先备份好,再添加以下语句:  <context-param><param-name>weblogic.httpd.inputCharset./*......
  • imp 中文乱码
    今天同事反应反馈数据的时候中文出现乱码。因为客户是一家外企所有操作系统的语言环境略微复杂.首先查数据库字符集 sql>select*fromv$nls_parameterswhereparame......
  • 解决网页乱码、打印文件乱码
    出现乱码可能的原因:编写网页时,使用的字符集和用户使用的字体集不一致比如,开发者使用utf-8字符集写下了如下网页:<!DOCTYPEhtml><htmllang="en"><head><metac......
  • ubuntu16.04中文乱码问题解决
    1、先输入locale-a,查看一下现在已安装的语言2、若不存在如zh_CN之类的语言包,进行中文语言包装:apt-getinstalllanguage-pack-zh-hans3、安装好后我们可以进行临时修......