View Single Post
  #5  
Old January 29th 08, 04:46 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Variables passed into HTML from VBA for a boilerplate template

In both cases, you need a string variable to contain the fully tagged HTML content.

..oft file -- load it with Application.CreateItemFromTemplate,then get its HTMLBody property

..txt file -- read the text into a variable with FileSystemObject methods; see http://msdn.microsoft.com/library/en...jsfsotutor.asp

I am assuming like this:

Set itm = Application.CreateItemFromTemplate("C:\myfile.oft" )
itm.HTMLBody = Replace(itm.HTMLBody, "%name%", "customer_name")


Exactly.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Nathan" wrote in message ...
Sue, Thanks for you quick response! Using this method how would I get VBA
to do a find through either the .oft file or through an HTM/HTML file to find
the field and replace with the inputbox variable? Also can I define a full
file and designate that as a variable that I can then set the ..htmlbody
method to?


Nathan Bell

"Sue Mosher [MVP-Outlook]" wrote:

I've done this by using placeholders in the HTML where the data from the InputBox result should go. For example, put %Field1% where you want one bit of data to appear, then use something like:

htmlText = Replace(htmlText, "%Field1%", "New Text")
myMessage.HTMLBody = htmlText




"Nathan" wrote in message ...
All,

I have a complex HTML e-mail message that I want to be able to customize
using variable in VBA. I don't want to have to go through the entire HTML
maessage and include in the the .htmlbody when creating a new message. I
would perfer to somehow pass variables that are set via an input box and then
pass them into the message in a template? Some variables are just text in
the message with HTML formatting and some variables are text+part of a
hyplerlink. Does anyone know wuick way to achieve this, I am just spinning
my wheels...


Ads