Connecting Tech Pros Worldwide Forums | Help | Site Map

CDO email an image

colinod's Avatar
Familiar Sight
 
Join Date: Nov 2007
Posts: 182
#1: Jul 14 '09
HI i am trying to add a company logo to a cdo email sent from our website.

the code i am using at the moment is

Expand|Select|Wrap|Line Numbers
  1. <%
  2. 'Sends an email
  3. Dim mail
  4. Set mail=Server.CreateObject("CDO.Message")
  5. mail.To=Request.Form("To")
  6. mail.From="jake@yaketyyak.co.uk"
  7. mail.Bcc=Request.Form("Bcc1")
  8. mail.Subject=Request.Form("Subject")
  9. mail.HTMLBody=Request.form("body2") & Request.Form("Body") & vbNewline & "<img src=http://www.yaketyyak.co.uk/images/makeup/letterheadsmall.jpg>" & vbNewline & Request.Form("Bodyfooter")
  10. mail.Send()
  11. Response.Write("")
  12. 'Destroy the mail object!
  13. Set mail = nothing
  14. %>
this sends the email perfectly but the image comes up with a red cross and no image, this i think is down to the missing " in the img src

The image source line in the email reads as follows

Expand|Select|Wrap|Line Numbers
  1. <img src=http://www.yaketyyak.co.uk/images/makeup/letterheadsmall.jpg>
I have tried various ways to code this line but cant get the inverted commas to appear

jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#2: Jul 14 '09

re: CDO email an image


try this
Expand|Select|Wrap|Line Numbers
  1. '...
  2. dim q
  3. q = chr(34)
  4. mail.HTMLBody=Request.form("body2") & Request.Form("Body") & vbNewline & "<img src=" & q & "http://www.yaketyyak.co.uk/images/makeup/letterheadsmall.jpg" & q & ">" & vbNewline & Request.Form("Bodyfooter")
  5. '...
that should solve the quote mark issue, I'm not sure it will resolve the issue of the img showing up.

Jared
colinod's Avatar
Familiar Sight
 
Join Date: Nov 2007
Posts: 182
#3: Jul 15 '09

re: CDO email an image


Hi Jared

I just added some inverted commas as the following and it worked

Expand|Select|Wrap|Line Numbers
  1. mail.HTMLBody=Request.form("body2") & Request.Form("Body") & vbNewline & "<img src=""http://www.yaketyyak.co.uk/images/makeup/letterheadsmall.jpg"">" & vbNewline & Request.Form("Bodyfooter")
Reply


Similar ASP / Active Server Pages bytes