Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-06-14
4
Medium Priority
?
4,605 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
  • 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

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

926 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