INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to embed image in e-mail ?

How to embed image in e-mail ?

(OP)
I will see an image at the end of my text e-mail.

...
myMail.textbody = myMail.textbody & "Yours sincerely," & vbCRLF
myMail.textbody = myMail.textbody & vbCRLF
myMail.textbody = myMail.textbody & vbCRLF
myMail.textbody = myMail.textbody & (image)

I was trying, but I do not know the correct code.
Is that possible in text or should I switch the e-mail to HTML-code ?

Thanks for tips (or example)

RE: How to embed image in e-mail ?

Images in emails will only be displayed in messages that are formatted as HTML and you can simply use a 'normal' HTML image element that links to URL. However "external" images may be blocked by spam filters. So to 'send' the image as part of the message rather than using an 'external' image you have to encode the image data in the src attribute as Base64 encoded text with

CODE

<img src="data:image/png;base64,[data]" alt="name.ext" > 

instead of

CODE

<img src="URL" alt="name.ext" > 
.

If it is always going to be the same image, such as a 'signature', it may be simpler to create a 'template' with "placeholders" and the encoded image already in place, with whatever mail client you use, and use that, the placeholder text is can then replaced by your script with the text required.


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: How to embed image in e-mail ?

How are you sending the email? You did not show how "myMail" is defined and what options you have set.

RE: How to embed image in e-mail ?

(OP)
To the attention of Guitarzan => e-mail send code

Set myMail=CreateObject("CDO.Message")

myMail.From="(adress)"
myMail.To=Session("(adress)")
myMail.textbody = "Dear " & session("(first name)") & "," & vbCRLF
myMail.textbody = myMail.textbody & vbCRLF
myMail.textbody = myMail.textbody & vbCRLF
...
myMail.textbody = myMail.textbody & "Yours sincerely," & vbCRLF
myMail.textbody = myMail.textbody & vbCRLF
myMail.textbody = myMail.textbody & vbCRLF

myMail.Send
set myMail=nothing

What do you mean by "options" ?
Thanks - Leif

RE: How to embed image in e-mail ?

(OP)
<OK, so you are using CDO>

Is there a better / easier method?
(I still have a problem adding the image)

Thx - Leifoet

RE: How to embed image in e-mail ?

Have you read the document at the first URL guitarzan provided?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: How to embed image in e-mail ?

>Is there a better / easier method?
When it comes to sending email in classic ASP, the best / easiest method is the one that works. CDO should be fine.

>I still have a problem adding the image
Well, what code did you try?

RE: How to embed image in e-mail ?

(OP)
I changed the text-code in HTML => it works.
...
myMail.HTMLbody = myMail.HTMLbody & "<BR><HR>"
myMail.HTMLbody = myMail.HTMLbody & "<img border='0' src='http://www.ABC.XY\image.jpg' alt='logo' ALIGN='left'>"
myMail.HTMLbody = myMail.HTMLbody & "<BR><BR><BR><BR><BR><BR><br>"
myMail.HTMLbody = myMail.HTMLbody & "<HR>"
myMail.HTMLbody = myMail.HTMLbody & "<BR>"

Finally, I try to put the contents of the HTML mail into a 2-column table.
Do I have to define the columns in pixels or in percent? => Email should also be "readable" on smartphone screens.
An example of such an HTML mail table might make it easier.
Thanks for tips.

RE: How to embed image in e-mail ?

Pixels are an absolute size so do not 'adjust' to browser window dimensions


https://www.w3schools.com/html/html_tables.asp

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close