+ Reply to Thread
Results 1 to 10 of 10

How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    Good morning,
    I have built a macro that generates an email from MS Outlook with predefined text, attachments, addressees, and buttons that link to a website. I currently have html code mingled with my vba, but I am wanting to have more stylish buttons and think I need to add in some CSS code. How is this done? Haven't been able to find any examples online. Is it even possible?

    Here is the relevant part of my code. If it is possible to add CSS code, where would it go and how is it transitioned in?

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    Re: How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    Here's an example of the sort of thing I'd like to add. The CSS below would add rounded corners to the emailBody3 button. My question is, where would I add this code into my current vba code? And would I need to put it all on one line, or does that not work? I've tried both ways already and nothing is working, but I might be missing something simple.

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    this worked for me :
    Please Login or Register  to view this content.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  4. #4
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    Re: How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    I should have clarified, "emailBody3" is one of the buttons I'd like to modify. Body1 and Body2 are just an image and text header. I couldn't get your code to work for either though. Do I need the indentation on line 2?

  5. #5
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    no need for the indentation.

    i do not see any <div> element in emailbody3 !

    please share the css that you wish to apply on emailbody3.

  6. #6
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    Re: How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    Well here is one design I was considering. Do I need a <div> element to use CSS?



    Please Login or Register  to view this content.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,208

    Re: How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    Email design is hard since there is little consistency as to how email clients will actually render the markup. If you limit the amount of places you are happy your email displaying correctly then things become easier. Would you be happy if your email only looked right on recent desktop versions of Outlook (and not Google mail, iphone, android mail, thunderbird, web outlook, live mail etc...)?

  8. #8
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    Re: How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    Good question Kyle,
    I would prefer to keep the email template more robust than not. So are you saying the CSS is incompatible with some email services? or is the code I currently have the issue?

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,208

    Re: How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    I'm saying that it's a combination of the two. You are already using css in your body, you've just inlined it:
    HTML Code: 
    style='-webkit-border-radius: 25px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;'
    You will need to do this for any rules you wish to use, many email clients strip off style tags so you can't use CSS classes. You're also using css3 properties which are not universally supported (if people are using IE7,8,9 and viewing their email online, your mail won't render properly, I suspect that it won't in Outlook 2003 either).

    There are frameworks out there for designing emails that render consistently - I use Ink http://zurb.com/ink/ FWIW

  10. #10
    Registered User
    Join Date
    06-23-2014
    Location
    MidWest, USA
    MS-Off Ver
    2016
    Posts
    89

    Re: How to Combine CSS, html, and vba to produce customized buttons on an Outlook email

    Thanks Kyle,
    That's helpful.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] HTML email into strings for use in Outlook
    By rmachbitz in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 09-01-2015, 04:32 PM
  2. excel to outlook email in HTML
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2014, 05:34 AM
  3. Macro to send saved draft email from outlook in HTML format
    By jamesshakedown in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-18-2013, 07:55 AM
  4. How to parse data in Outlook email using HTML version of email back to excel
    By bnasty in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 10-31-2012, 02:54 PM
  5. Using Excel 2007 to Prepare an Email in Outlook 2007 in a customized format.
    By rahulin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2010, 08:36 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1