How to send an image as an attachment without saving it to the file system?

I have one aspx page whose contents are:

The code:

<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/JD.jpg" /> 

OR

 <img ID="Image2" runat="server" alt="" src="~/Images/JD.jpg" /> 

Do I need to send this image as an attachment in the mail without saving to the file system?

Actallay I need to send an error report to the mail ... I like that this user takes a screenshot and sends it to the administrator ...

Please suggest me ..

+1
source share
1 answer

This is for reference only.
Sending email with an attachment in ASP.NET using an 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; } } 
+4
source

Source: https://habr.com/ru/post/903720/


All Articles