<bdo id='CIVie'></bdo><ul id='CIVie'></ul>
    <legend id='CIVie'><style id='CIVie'><dir id='CIVie'><q id='CIVie'></q></dir></style></legend>
  1. <tfoot id='CIVie'></tfoot>
  2. <small id='CIVie'></small><noframes id='CIVie'>

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

      在 C# 的邮件正文中附加图像

      Attaching Image in the body of mail in C#(在 C# 的邮件正文中附加图像)

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

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

                本文介绍了在 C# 的邮件正文中附加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如何在正文内容中附加图像.我写了下面的代码

                How can I attach an image in the body content . I have written the below code

                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                string UserName = "xyz@someorg.com";
                string Password = "my password";
                message.To.Add(new System.Net.Mail.MailAddress("toaddress@toadddress.com"));
                message.From = new  System.Net.Mail.MailAddress("fromaddress@fromaddress.com");              
                message.Subject = "test subject";
                message.Body = "<img src=@'C:\Sunset.jpg'/>";                
                message.IsBodyHtml = true;
                System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
                 smtpClient.Host = "hostname";
                 smtpClient.Port = 25;
                 smtpClient.Credentials = new System.Net.NetworkCredential(UserName, Password);
                 smtpClient.Send(message);
                

                代码很好,因为我也收到了消息,但图像在正文中以 [X] 的形式出现,而不是图像.如何解决这个问题?路径正确吗?

                The code is fine as I am receiving the message also but the image is coming as [X] inside the body and not as the image. How to solve this? The path is correct?

                推荐答案

                    string attachmentPath = Environment.CurrentDirectory + @"	est.png";
                    Attachment inline = new Attachment(attachmentPath);
                    inline.ContentDisposition.Inline = true;
                    inline.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
                    inline.ContentId = contentID;
                    inline.ContentType.MediaType = "image/png";
                    inline.ContentType.Name = Path.GetFileName(attachmentPath);
                
                    message.Attachments.Add(inline);
                

                <小时>

                参考:使用 C# 发送带有内联附件的电子邮件

                这篇关于在 C# 的邮件正文中附加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 列表框上的取消选择)

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

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

                          <tbody id='HO0Kh'></tbody>

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