如何发送图像attachement而不保存在文件系统? [英] How to send image as attachement without saving it in file system?
本文介绍了如何发送图像attachement而不保存在文件系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个aspx页面哪些内容:
I have one aspx page which content :
code:
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/JD.jpg" />
或
<img ID="Image2" runat="server" alt="" src="~/Images/JD.jpg" />
我要送这个形象邮件attachement没有在文件系统中保存?
I have to send this image as attachement in mail without saving in file system?
Actallay我要送邮件bug报告......这就像服用用户的屏幕截图,发送给管理员...
Actallay i have to send bug report in mail...It's like that user taking screen shot and send to admin...
请给我建议。
推荐答案
这仅供参考。
使用ASP.NET带附件发送电子邮件SMTP服务器
/* Beginning of Attachment1 process &
Check the first open file dialog for a attachment */
if (inpAttachment1.PostedFile != null)
{
/* Get a reference to PostedFile object */
HttpPostedFile attFile = inpAttachment1.PostedFile;
/* Get size of the file */
int attachFileLength = attFile.ContentLength;
/* Make sure the size of the file is > 0 */
if (attachFileLength > 0)
{
/* Get the file name */
strFileName = Path.GetFileName(inpAttachment1.PostedFile.FileName);
/* Save the file on the server */
inpAttachment1.PostedFile.SaveAs(Server.MapPath(strFileName));
/* Create the email attachment with the uploaded file */
MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
/* Attach the newly created email attachment */
mailMessage.Attachments.Add(attach);
/* Store the attach filename so we can delete it later */
attach1 = strFileName;
}
}
这篇关于如何发送图像attachement而不保存在文件系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文