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
Solved

VBS for BodyFormat = olFormatRichText - making an outlook email look better?

Posted on 2008-10-28
1
2,038 Views
Last Modified: 2012-06-27
Hi, using VB, how would I set a line of my code, to generate some text in bold/italic/underline?
At the moment, its all plain txt.
Im using outlook 2003 and excel as a bulk email generator.

myItem.BodyFormat = olFormatRichText
myItem.Body = _
            "Dear " & Trim(ManagerFirstName) & "," & vbCrLf _
            & vbCrLf _
            & "I want this txt to be bold" & vbCrLf _
            & vbCrLf _
            & ApplicationName & " I want this to be in red font and underlined." & vbCrLf _
            & vbCrLf _

So using the richtext feature, how do I add rich text
I would rather not use HTML if possible, unless this is a lot easier/better

also, if your posting links, can you also post some text (from the link too) as the internet in the office doesnt let you get onto many sites - please!
0
Comment
Question by:jamiepryer
1 Comment
 
LVL 3

Accepted Solution

by:
Angelized earned 250 total points
ID: 22822276
This basically how to code and HTML message ( i found it personnaly easier than RTF)
The best is to create your message with outlook (switch it to HTML and view source)
You can use of course any HTML editor.
.HTMLBody  Will contain the string. what you need to do once you have the template created   is to replace the field with what you need. Here is an example attached.
Firstname, lastname and ADID are variable that you need to fill out. (like Trim(ManagerFirstName) in your example.
How this is enought as a first draft, lemme know if you need more info.

 verdana = "<P><font size=2 color=navy  face = Verdana >"
      Size2 = "<P><FONT size=2>"
      HtmlEnd = "</FONT></P>"
      htmlBreak = "<P></P>"
      HtmlMsg = verdana & "Hi," & HtmlEnd
      HtmlMsg = HtmlMsg & verdana & "The following, Active Directory account has been updated :" & HtmlEnd & verdana
      HtmlMsg = HtmlMsg & "<TABLE><TBODY>"
      HtmlMsg = HtmlMsg & "<FONT face=Verdana size=0>"
      HtmlMsg = HtmlMsg & "<TR><TD><B>" & Size2 & "First Name: </B></TD> <TD>" & Size2 & FirstName & "</TD></TR>"
      HtmlMsg = HtmlMsg & "<TR><TD><B>" & Size2 & "Last Name: </B></TD> <TD>" & Size2 & Lastanme & "</TD></TR>"
      HtmlMsg = HtmlMsg & "<TR><TD><B>" & Size2 & "Active Directory ID: </B></TD> <TD>" & Size2 & ADID & "</TD></TR>"
      HtmlMsg = HtmlMsg & "</FONT>"
      HtmlMsg = HtmlMsg & "</TBODY></TABLE>"
      .HTMLBody = HtmlMsg

Open in new window

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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