Jump to content

Outlook Template automation


Recommended Posts

Hello, I am trying to open an Outlook template, edit the contents depending on user input, and then generate a message with the updated information. So far, I have been able to take care of everything except editing the html in the body (Thanks to Waters and the useful UDF). Basically, the body is html (edited and formatted) and I cannot find a way to edit it properly. So if the body in the template says "Hello, John" and the user chooses the name to be "George", I would like to replace it accordingly. What would be the best approach to doing so? Any help is greatly appreciated.

Link to comment
Share on other sites

If you use my UDF you simply would read the HTMLBody property of the mail item to a variable by using function _OL_ItemGet. Make the necessary modifications to the variable and then set the property by using function _OL_ItemModify.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Example 5 in _OL_ItemCreate.au3 example script shows how to create a mail item from a template.

Use the returned item object to call _OL_ItemGet, change the HTML body and set the property again:

$aProperties = _OL_ItemGet($oOL, $oItem, Default, "HTMLBody")
$sHTMLBody = $aProperties[1][1]
$sHTMLBody = "Modify the HTMP Body here"
_OL_ItemModify($oOL, $oItem, Default, "HTMLBody=" & $sHTMLBody)
Untested and error checking is missing!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...