0

I'm using asp.net/vb.net. I have code which dynamically generates a mailto link, complete with the email address, subject, body, etc....

In the database users table I have some fields, Signature, LogoFile and LogoFileName. I want to manually append this, if possible, to the body. In effect it's an auto signature.

No problem when it comes to the actual text, Signature. But, how can I get the mailto link to somehow show/reference the logo image in the body? The actual image is stored IN the database. Of course, if the file was on a webserver I could just reference the url. But, in this case it's not stored on the file system.

Any ideas would be appreciated. Thanks!

WebDevGuy2
  • 1,159
  • 1
  • 19
  • 40
  • possible duplicate of [How to embed images in email](http://stackoverflow.com/questions/4312687/how-to-embed-images-in-email) – Andrew Morton Feb 24 '15 at 20:03

1 Answers1

0

You won't be able to do this with a mailto: protocol link.

I recommend building/designing an HTML template that includes a placeholder where your image will go, along with placeholders for any other individualized body content.

In general terms:

  1. The link would be a LinkButton control, that, when clicked, will initiate a postback to the server.
  2. In the event handler for the button, you'd grab the HTML email template.
  3. Make the appropriate database calls to get the data you need.
  4. Replace the placeholders in the HTML with the absolute URL to the image (and any other data that should be merged into the template), or embed the image into the email itself.
  5. Create the email using the MailMessage class, including subject line, to, from, body, etc.
  6. Send the email with the SmtpClient class.
Tim S. Van Haren
  • 8,861
  • 2
  • 30
  • 34