Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MODIFY FORMAT AND COLOR IN A OUTLOOK MESSAGE FROM EXCEL USING VBA

Posted on 2013-06-14
4
Medium Priority
?
4,466 Views
Last Modified: 2013-06-14
Hi,

I am using a VBA code to send emails using outlook from excel VBA, I want to be able to modify some parts of the body like changing color, font...? Is this possible?
0
Comment
Question by:joyacv2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 39247574
Hi,

it is possible to do it by sending an HTML Text

Sub CreateHTMLMail()
'Creates a new e-mail item and modifies its properties.

    Dim olApp As Outlook.Application
    Dim objMail As Outlook.MailItem
    Set olApp = Outlook.Application
    'Create e-mail item
    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
       'Set body format to HTML
       .BodyFormat = olFormatHTML
       .HTMLBody = "<HTML><BODY>Enter the <b>message</b> text here. </BODY></HTML>"
       .Display
    End With
End Sub

Open in new window

0
 
LVL 1

Author Comment

by:joyacv2
ID: 39247651
Hi

Do you know how specify a color in this code?
0
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39247695
Hi,

Please refer to

http://html-color-codes.info/#How_to_use_html_color_codes

Sub CreateHTMLMail()
'Creates a new e-mail item and modifies its properties.

    Dim olApp As Outlook.Application
    Dim objMail As Outlook.MailItem
    Set olApp = Outlook.Application
    'Create e-mail item
    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
       'Set body format to HTML
       .BodyFormat = olFormatHTML
       .HTMLBody = "<HTML><BODY><span style=""color:#80BFFF"">Enter</span style=""color:#80BFFF""> the <b>message</b> text here. </BODY></HTML>"
       .Display
    End With
End Sub

Open in new window

Regards
0
 
LVL 1

Author Closing Comment

by:joyacv2
ID: 39247734
Excellent Solution
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Changing a few Outlook Options can help keep you organized!
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question