如何在smtp邮件实现中附加文件 [英] How to attach a file in smtp mail implementation

查看:84
本文介绍了如何在smtp邮件实现中附加文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我已经在我的asp.net应用程序中通过SMTP实现发送邮件。

我想使用附加文件超链接按钮。

怎么做?



谢谢

Hello,

I have implemented sending mails through SMTP in my asp.net application.
I want to attach a file using hyperlink button.
How to do that?

Thanks

推荐答案

您将在我过去的帖子中找到答案:发送带图像的HTML附件 [ ^ ]。



附件一词非常具有误导性。这些文件永远不会附加到任何邮件消息。邮件消息可以是多部分,某些部分可以是编码为base64文本的文件。它有自己的部分标题,内容类型显示如何处理文件,上下文处理建议邮件查看器应用程序如何处理该部分。我的过去的答案只是解释了如何引用另一部分中的一个部分,如HTML锚点。



参见: http://en.wikipedia.org/wiki/MIME [ ^ ]。



-SA
You will find the answer in my past post: Sending HTML attachment with images[^].

The term "attachment" is very misleading. The files are never "attached" to any mail message. A mail message can be multipart, and some part can be a file coded as base64 text. It has its own part headers, with content type showing how to process the file, and context disposition suggesting the mail viewer application what to do with the part. My past answer just explains how to reference a part in another part, as HTML anchor.

See also: http://en.wikipedia.org/wiki/MIME[^].

—SA


使用以下代码:



System.Net.Mail.Attachment附件;

attachment = new System.Net.Mail.Attachment(C :\ mail_attach.jpg);

mail.Attachments.Add(附件);
use the below code:

System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("C:\mail_attach.jpg");
mail.Attachments.Add(attachment);


这篇关于如何在smtp邮件实现中附加文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆