我有一个aspx页面内容:
代码:
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/JD.jpg" />
OR
<img ID="Image2" runat="server" alt="" src="~/Images/JD.jpg" />
我必须将此图像作为附件发送而不保存在文件系统中吗?
Actallay我必须通过邮件发送错误报告...就像那个用户拍摄屏幕截图并发送给管理员...
请建议我..
答案 0 :(得分:4)
仅供参考 Sending Email with attachment in ASP.NET using SMTP Server
/* 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;
}
}