CDO.Message background image

Discussion in 'ASP General' started by Guest, Jul 25, 2005.

  1. Guest

    Guest 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.
    Guest, Jul 25, 2005
    #1
    1. Advertising

  2. > 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.
    Aaron Bertrand [SQL Server MVP], Jul 25, 2005
    #2
    1. Advertising

  3. Guest

    Guest 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.
    Guest, Jul 25, 2005
    #3
  4. > 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).
    Aaron Bertrand [SQL Server MVP], Jul 25, 2005
    #4
  5. Guest

    Guest 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!
    Guest, Jul 25, 2005
    #5
  6. >> <body background=http://whatever>
    >
    > 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?
    Aaron Bertrand [SQL Server MVP], Jul 25, 2005
    #6
  7. Guest

    Guest 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 = ""
    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.
    Guest, Jul 25, 2005
    #7
  8. Aaron Bertrand [SQL Server MVP], Jul 25, 2005
    #8
  9. Guest

    Guest 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!
    Guest, Jul 25, 2005
    #9
  10. Guest

    Guest Guest

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


    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=""
    myMail.To=""
    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/"
    Guest, Jul 25, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    2
    Views:
    856
    dave wanta
    Jul 11, 2003
  2. jc
    Replies:
    3
    Views:
    1,712
  3. jc
    Replies:
    1
    Views:
    1,352
    Neredbojias
    Mar 19, 2008
  4. Replies:
    0
    Views:
    265
  5. Dj Frenzy
    Replies:
    3
    Views:
    292
    Robert
    Feb 10, 2004
Loading...

Share This Page