CDOSYS and CSS being ignored

Discussion in 'ASP General' started by James, Aug 20, 2007.

  1. James

    James Guest

    Hello,
    I've been testing HTML messages both with CreateMHTMLBody and
    HTMLBody, the problem is that the message delivered does not display
    css styles correctly. If I use "style" inside html tags within the
    "body" the style is applyed. But if I put the styles within the "head"
    tags and then reference to them with "class" the styles get completely
    ignored.

    The complete html code obviusly displays well on browsers.

    Here are few lines of code

    Set objMail = CreateObject("CDO.Message")
    objMail.From = "'
    objMail.To = ""
    objMail.Subject = "sbj"

    txt = txt & "<html>"
    txt = txt & "<head>"
    txt = txt & "<META http-equiv='Content-Type' content='text/html;
    charset=iso-8859-1'>"
    txt = txt & "<style type='text/css'>"
    txt = txt & "<!--"
    txt = txt & ".notapplied {font-family: Arial, Helvetica, sans-serif;
    color: #074B89; font-size: 56px; font-weight: bold; }"
    txt = txt & "-->"
    txt = txt & "</style>"
    txt = txt & "</head>"
    txt = txt & "<body>"
    txt = txt & "<br><h1 style='font-family: Arial, Helvetica, sans-serif;
    color: #074B89; font-size: 56px; font-weight: bold;'>applied</h1>"
    txt = txt & "<br><h1 class='notapplied'>not applied</h1>"
    txt = txt & "</body>"
    txt = txt & "</html>"

    objMail.HTMLBody = txt
    objMail.Send()
    set objMail = Nothing

    Thanks and happy coding
    J
     
    James, Aug 20, 2007
    #1
    1. Advertising

  2. "James" <> wrote in message
    news:...
    > Hello,
    > I've been testing HTML messages both with CreateMHTMLBody and
    > HTMLBody, the problem is that the message delivered does not display
    > css styles correctly. If I use "style" inside html tags within the
    > "body" the style is applyed. But if I put the styles within the "head"
    > tags and then reference to them with "class" the styles get completely
    > ignored.
    >
    > The complete html code obviusly displays well on browsers.
    >
    > Here are few lines of code
    >
    > Set objMail = CreateObject("CDO.Message")
    > objMail.From = "'
    > objMail.To = ""
    > objMail.Subject = "sbj"
    >
    > txt = txt & "<html>"
    > txt = txt & "<head>"
    > txt = txt & "<META http-equiv='Content-Type' content='text/html;
    > charset=iso-8859-1'>"
    > txt = txt & "<style type='text/css'>"
    > txt = txt & "<!--"
    > txt = txt & ".notapplied {font-family: Arial, Helvetica, sans-serif;
    > color: #074B89; font-size: 56px; font-weight: bold; }"
    > txt = txt & "-->"
    > txt = txt & "</style>"
    > txt = txt & "</head>"
    > txt = txt & "<body>"
    > txt = txt & "<br><h1 style='font-family: Arial, Helvetica, sans-serif;
    > color: #074B89; font-size: 56px; font-weight: bold;'>applied</h1>"
    > txt = txt & "<br><h1 class='notapplied'>not applied</h1>"
    > txt = txt & "</body>"
    > txt = txt & "</html>"
    >
    > objMail.HTMLBody = txt
    > objMail.Send()
    > set objMail = Nothing
    >



    Ignored by what? Outlook Express? Outlook? Thunderbird? A Web based email
    agent like Gmail or hotmail?



    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 20, 2007
    #2
    1. Advertising

  3. James

    James Guest

    On Mon, 20 Aug 2007 21:11:29 +0100, "Anthony Jones" wrote:

    >Ignored by what? Outlook Express? Outlook? Thunderbird? A Web based email
    >agent like Gmail or hotmail?


    Ignored by Gmail web interface, OE displays both solutions correctly.

    Anyway I do receive html mails with css in the head, as a matter of
    fact the MSDN newsletter has css in the head and looks perfect via
    web.

    What can it be?

    Thanks
    J
     
    James, Aug 21, 2007
    #3
  4. "James" <> wrote in message
    news:p...
    > On Mon, 20 Aug 2007 21:11:29 +0100, "Anthony Jones" wrote:
    >
    > >Ignored by what? Outlook Express? Outlook? Thunderbird? A Web based

    email
    > >agent like Gmail or hotmail?

    >
    > Ignored by Gmail web interface, OE displays both solutions correctly.
    >
    > Anyway I do receive html mails with css in the head, as a matter of
    > fact the MSDN newsletter has css in the head and looks perfect via
    > web.
    >
    > What can it be?
    >


    I don't know anything about GMail you would have to ask some where more
    appropriate for GMail questions.


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Aug 21, 2007
    #4
  5. "James" <> wrote in message
    news:p...
    > On Mon, 20 Aug 2007 21:11:29 +0100, "Anthony Jones" wrote:
    >
    >>Ignored by what? Outlook Express? Outlook? Thunderbird? A Web based email
    >>agent like Gmail or hotmail?

    >
    > Ignored by Gmail web interface, OE displays both solutions correctly.
    >
    > Anyway I do receive html mails with css in the head, as a matter of
    > fact the MSDN newsletter has css in the head and looks perfect via
    > web.
    >
    > What can it be?


    Examine the names used for class definitions in the working MSDN newsletter,
    then examine yours.

    It's quite possible that you've used one or more names which overlap those
    used by Google.

    --
    Bob Milutinovic
    Cognicom - "Australia's Web Presence Specialists"
    http://www.cognicom.net.au/
    telephone (0417) 45-77-66
    facsimile (02) 9824-2240
     
    Bob Milutinovic, Sep 2, 2007
    #5
    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. =?Utf-8?B?Q2hyaXM=?=

    ASP.NET Server.ScriptTimeout being ignored

    =?Utf-8?B?Q2hyaXM=?=, May 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    5,429
    Cowboy \(Gregory A. Beamer\)
    May 14, 2004
  2. David Hearn
    Replies:
    1
    Views:
    665
    Ken Dopierala Jr.
    Oct 27, 2004
  3. Rigga

    Div being ignored

    Rigga, Jul 13, 2004, in forum: HTML
    Replies:
    7
    Views:
    911
    Mark Parnell
    Jul 14, 2004
  4. Christian Seberino
    Replies:
    5
    Views:
    842
    Christian Seberino
    Oct 9, 2003
  5. rschaeferhig
    Replies:
    4
    Views:
    254
Loading...

Share This Page