1

So let's say that there is a HTML (or XHTML) code and

<img alt="...." src=".......aspx" />:

So, aspx generates image file, and there will be some image shown.

Now I want to send the generated image file to E-mail or using HTML form code, and I want my html code to do this automatically.

So, in the html code, after img code, I'd like to add codes that send the generated image automatically.

(I want a single code with img code and E-mail or HTML form code.)

What should I do?

user1441174
  • 47
  • 1
  • 4
  • 1
    Can you clarify - "send the generated image file to E-mail" - on the server side, or on the client side (in the browser)? What would trigger it? – Mr. TA Jun 07 '12 at 17:35
  • @Mr.TA So, the code will show some image to a user. I want that image to be sent to an E-mail. (as src is aspx, it'll show different images for different time.) – user1441174 Jun 07 '12 at 17:43
  • @Mr.TA and I edited the question, hope this clarifies:) – user1441174 Jun 07 '12 at 17:46

2 Answers2

1

To be honest, based on your question, it's not entirely clear what you're trying to accomplish. But, from what I gather, you could try several different approaches:

  1. Check out this StackOverflow post: Sending an email with an image embedded in the body from C#

  2. You can use the code from this source as a starting point: http://www.codedigest.com/Articles/ASPNET/95_Sending_Email_using_C__and_ASPNet_20.aspx (see "Sending Email with Embedded Image in the Message Body" section)

Community
  • 1
  • 1
lkaradashkov
  • 8,609
  • 1
  • 15
  • 12
0

What you need to do is move the image generation logic to some library or the App_Code folder, and then call that logic twice: once from the .aspx handler that sends it for the tag, and once for the code that you also need to write that will send it in the email. Once you have the byte[] array with the image, follow lkaradashkov's link to send it in the email:

Sending an email with an image embedded in the body from C#

Community
  • 1
  • 1
Mr. TA
  • 5,230
  • 1
  • 28
  • 35