<tfoot id='IgUVe'></tfoot>
    1. <i id='IgUVe'><tr id='IgUVe'><dt id='IgUVe'><q id='IgUVe'><span id='IgUVe'><b id='IgUVe'><form id='IgUVe'><ins id='IgUVe'></ins><ul id='IgUVe'></ul><sub id='IgUVe'></sub></form><legend id='IgUVe'></legend><bdo id='IgUVe'><pre id='IgUVe'><center id='IgUVe'></center></pre></bdo></b><th id='IgUVe'></th></span></q></dt></tr></i><div id='IgUVe'><tfoot id='IgUVe'></tfoot><dl id='IgUVe'><fieldset id='IgUVe'></fieldset></dl></div>

        <legend id='IgUVe'><style id='IgUVe'><dir id='IgUVe'><q id='IgUVe'></q></dir></style></legend>
        • <bdo id='IgUVe'></bdo><ul id='IgUVe'></ul>

        <small id='IgUVe'></small><noframes id='IgUVe'>

      1. 从 C# 发送带有附件的电子邮件,附件在 Thunderbird 中作为第 1.2 部分到达

        Sending email with attachments from C#, attachments arrive as Part 1.2 in Thunderbird(从 C# 发送带有附件的电子邮件,附件在 Thunderbird 中作为第 1.2 部分到达)
      2. <i id='KNED6'><tr id='KNED6'><dt id='KNED6'><q id='KNED6'><span id='KNED6'><b id='KNED6'><form id='KNED6'><ins id='KNED6'></ins><ul id='KNED6'></ul><sub id='KNED6'></sub></form><legend id='KNED6'></legend><bdo id='KNED6'><pre id='KNED6'><center id='KNED6'></center></pre></bdo></b><th id='KNED6'></th></span></q></dt></tr></i><div id='KNED6'><tfoot id='KNED6'></tfoot><dl id='KNED6'><fieldset id='KNED6'></fieldset></dl></div>
          <bdo id='KNED6'></bdo><ul id='KNED6'></ul>
            <tbody id='KNED6'></tbody>

          <small id='KNED6'></small><noframes id='KNED6'>

                <tfoot id='KNED6'></tfoot><legend id='KNED6'><style id='KNED6'><dir id='KNED6'><q id='KNED6'></q></dir></style></legend>

                1. 本文介绍了从 C# 发送带有附件的电子邮件,附件在 Thunderbird 中作为第 1.2 部分到达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 C# 应用程序,它使用 SMTP 通过 Exchange 2007 服务器通过电子邮件发送 Excel 电子表格报告.这些附件对 Outlook 用户来说很好,但对于 Thunderbird 和 Blackberry 用户,附件已重命名为第 1.2 部分".

                  I have a C# application which emails out Excel spreadsheet reports via an Exchange 2007 server using SMTP. These arrive fine for Outlook users, but for Thunderbird and Blackberry users the attachments have been renamed as "Part 1.2".

                  我发现这篇 文章 描述了问题,但没有t 似乎给了我一个解决方法.我无法控制 Exchange 服务器,因此无法在那里进行更改.在 C# 端有什么我可以做的吗?我曾尝试对正文使用短文件名和 HTML 编码,但都没有改变.

                  I found this article which describes the problem, but doesn't seem to give me a workaround. I don't have control of the Exchange server so can't make changes there. Is there anything I can do on the C# end? I have tried using short filenames and HTML encoding for the body but neither made a difference.

                  我的邮件发送代码是这样的:

                  My mail sending code is simply this:

                  public static void SendMail(string recipient, string subject, string body, string attachmentFilename)
                  {
                      SmtpClient smtpClient = new SmtpClient();
                      NetworkCredential basicCredential = new NetworkCredential(MailConst.Username, MailConst.Password);
                      MailMessage message = new MailMessage();
                      MailAddress fromAddress = new MailAddress(MailConst.Username);
                  
                      // setup up the host, increase the timeout to 5 minutes
                      smtpClient.Host = MailConst.SmtpServer;
                      smtpClient.UseDefaultCredentials = false;
                      smtpClient.Credentials = basicCredential;
                      smtpClient.Timeout = (60 * 5 * 1000);
                  
                      message.From = fromAddress;
                      message.Subject = subject;
                      message.IsBodyHtml = false;
                      message.Body = body;
                      message.To.Add(recipient);
                  
                      if (attachmentFilename != null)
                          message.Attachments.Add(new Attachment(attachmentFilename));
                  
                      smtpClient.Send(message);
                  }
                  

                  感谢您的帮助.

                  推荐答案

                  显式填写 ContentDisposition 字段就可以了.

                  Explicitly filling in the ContentDisposition fields did the trick.

                  if (attachmentFilename != null)
                  {
                      Attachment attachment = new Attachment(attachmentFilename, MediaTypeNames.Application.Octet);
                      ContentDisposition disposition = attachment.ContentDisposition;
                      disposition.CreationDate = File.GetCreationTime(attachmentFilename);
                      disposition.ModificationDate = File.GetLastWriteTime(attachmentFilename);
                      disposition.ReadDate = File.GetLastAccessTime(attachmentFilename);
                      disposition.FileName = Path.GetFileName(attachmentFilename);
                      disposition.Size = new FileInfo(attachmentFilename).Length;
                      disposition.DispositionType = DispositionTypeNames.Attachment;
                      message.Attachments.Add(attachment);                
                  }
                  

                  顺便说一句,对于 Gmail,您可能会遇到一些关于 ssl 安全甚至端口的例外情况!

                  BTW, in case of Gmail, you may have some exceptions about ssl secure or even port!

                  smtpClient.EnableSsl = true;
                  smtpClient.Port = 587;
                  

                  这篇关于从 C# 发送带有附件的电子邮件,附件在 Thunderbird 中作为第 1.2 部分到达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)

                    • <legend id='Ad0Lw'><style id='Ad0Lw'><dir id='Ad0Lw'><q id='Ad0Lw'></q></dir></style></legend>

                          <tbody id='Ad0Lw'></tbody>
                          <bdo id='Ad0Lw'></bdo><ul id='Ad0Lw'></ul>

                          <i id='Ad0Lw'><tr id='Ad0Lw'><dt id='Ad0Lw'><q id='Ad0Lw'><span id='Ad0Lw'><b id='Ad0Lw'><form id='Ad0Lw'><ins id='Ad0Lw'></ins><ul id='Ad0Lw'></ul><sub id='Ad0Lw'></sub></form><legend id='Ad0Lw'></legend><bdo id='Ad0Lw'><pre id='Ad0Lw'><center id='Ad0Lw'></center></pre></bdo></b><th id='Ad0Lw'></th></span></q></dt></tr></i><div id='Ad0Lw'><tfoot id='Ad0Lw'></tfoot><dl id='Ad0Lw'><fieldset id='Ad0Lw'></fieldset></dl></div>
                          <tfoot id='Ad0Lw'></tfoot>

                          <small id='Ad0Lw'></small><noframes id='Ad0Lw'>