问题描述
|
我有一个aspx页面,内容:
码:
<asp:Image ID=\"Image1\" runat=\"server\" ImageUrl=\"~/Images/JD.jpg\" />
要么
<img ID=\"Image2\" runat=\"server\" alt=\"\" src=\"~/Images/JD.jpg\" />
我必须以附件形式发送此图像而不保存在文件系统中吗?
Actallay我必须通过邮件发送错误报告...就像该用户截屏并发送给管理员...
请建议我..
解决方法
仅供参考。
使用SMTP服务器在ASP.NET中发送带有附件的电子邮件
/* 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;
}
}