CDO.Message background image

G

Guest

Hi - is it possible to set an image as the background body image
(non-repeating too) in a message sent using CDO. I don't want to embed an
external webpage (I have to insert user form related variables back in the
body of the email) and the image is on the server the mail is being
generated from - have googled for ages on this one but can't seem to find
anything suitable...

Thanks for any help on this.
 
A

Aaron Bertrand [SQL Server MVP]

Hi - is it possible to set an image as the background body image

Yes, use MHTMLBody.
http://www.aspfaq.com/2474
See "Embedding images in the e-mail"
(non-repeating too)

This is an HTML/CSS issue. You would use the same style settings as you
would in any other HTML page. Please follow up for this part of it in an
HTML/CSS newsgroup.
 
G

Guest

Hi - is it possible to set an image as the background body image
Yes, use MHTMLBody.
http://www.aspfaq.com/2474
See "Embedding images in the e-mail"

Well, thanks - but do I really have to embed a webpage and create further
asp code just to grab the variables I wanted to put in the email in that
seperate asp page?

Sounds like a lot more work for something that should be a couple more lines
of code! I've already html'd my code as much as I wanted to - I just wanted
now to put a background image in. I'm already using .HTMLBody - just thought
there might be a one liner to insert the background image in.

If you're saying there isn't - that's a real shame.
 
A

Aaron Bertrand [SQL Server MVP]

Well, thanks - but do I really have to embed a webpage and create further
asp code just to grab the variables I wanted to put in the email in that
seperate asp page?

Sorry, somehow I thought you wanted to attach it without having to reference
it.

If all of the rest of your images are being referenced from online (e.g.
<img src=http://whatever>) can't you do the same for the background?

<body background=http://whatever>

And again, as for the non-repeating part, you can apply this with CSS
(off-topic here).
 
G

Guest

Sorry, somehow I thought you wanted to attach it without having to
reference it.

That's OK - maybe I should have been clearer.
If all of the rest of your images are being referenced from online (e.g.
<img src=http://whatever>) can't you do the same for the background?

<body background=http://whatever>

No! It just doesn't work! All the other elements in the HTML work - except
for this - I have tried the http path, the C:\ path, the relative path and
none of them work! That's why I came here to post!
 
A

Aaron Bertrand [SQL Server MVP]

No! It just doesn't work!

What about setting the background of a table, or a table cell, or using CSS
e.g. BODY { background-image:url(http://www.whatever.com/whatever.gif); })?
Please follow up in a CSS or HTML newsgroup for different ways to apply a
background image.
All the other elements in the HTML work - except for this - I have tried
the http path, the C:\ path, the relative path and none of them work!

C:\ and relative will never work if you send the e-mail anywhere... I think
it may be a mail client issue, how many different clients have you tested?
Just yours?
 
G

Guest

What about setting the background of a table, or a table cell, or using
CSS e.g. BODY {
background-image:url(http://www.whatever.com/whatever.gif); })?

Same again! I've even tried posting the variables to a new asp page like you
suggested with CreateMHTMLBody = myURL but that doesn't work either - I get
a 500 internal server error : ( this is really getting on my nerves now. It
should be so easy.
C:\ and relative will never work if you send the e-mail anywhere... I
think it may be a mail client issue, how many different clients have you
tested? Just yours?

Yes, but as its plain old OE I'm sure 60-70% of users have it or derivatives
that work in the same way as it. Its just got to work!

Perhaps you could explain what's wrong with this code that's causing the 500
internal server error -

<%
If Request.Form("process") = "True" Then
formToName = Request.Form("to_name")
formFromName = Request.Form("from_name")
formEmailTo = Request.Form("to_email")

makeURL = "http://www.ourserver.com/thepage.asp?to_name=" & formToName &
"from_name=" & formFromName & ""


Set MyCDONTSMail = CreateObject("CDO.Message")
MyCDONTSMail.From = "(e-mail address removed)"
MyCDONTSMail.To = formEmailTo
MyCDONTSMail.Subject = "ourtext"
MyCDONTSMail.CreateMHTMLBody makeURL
MyCDONTSMail.Send
Set MyCDONTSMail=nothing

End If
%>

and then in the thepage.asp:

<%
formToName = Request.querystring("to_name")
formFromName = Request.querystring("from_name")
%>

and in the body of thepage.asp

<%
formToName=Request.querystring("to_name")
Response.Write(formToName)
%>

I know its not perfect code yet as I'm still testing but this throws up
errors! Why?!

Arrghhh. Its one of those days where a little thing spiralls into a
troublesome thing.
 
G

Guest

I get a 500 internal server error : (
(a) on which page?

Well I wasn't sure which page it meant the error was coming from because the
application essentially inserted another asp page's generated html page into
an email - now I've switched off the friendly errors I've tracked down the
error to access is denied on the line that says:

MyCDONTSMail.CreateMHTMLBody makeURL

So I simplified the line to just go to another asp which does work, with the
same result!

Odd! ...and infuriating!
 
G

Guest

I get a 500 internal server error : (
Sorry - I realised my last message might not have made sense. Basically the
problem is that this standard code
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="(e-mail address removed)"
myMail.To="(e-mail address removed)"
myMail.CreateMHTMLBody "http://www.w3schools.com/asp/"
myMail.Send
set myMail=nothing
%>throws up the error Access is denied on the linemyMail.CreateMHTMLBody
"http://www.w3schools.com/asp/"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,010
Latest member
MerrillEic

Latest Threads

Top