I want to insert variable data into an Outlook template

I have an e-mail that I send out every day and the text is the same, but every day I have to change the date and four dollar amounts.  I have set this e-mail up as an Outlook template but I still have to manually go in and edit the same fields every day.  Is there a way to use Mail Merge, macros, or some other feature so that I can just key in this information into a field somewhere and it automatically inserts it into the appropriate place in the template?  Just overwriting the data isn't really working, I always manage to forget to change something.  Please let me know if anyone has any ideas.  Thanks!  
Answer
Answer

Start with opening the VBA editor (press alt+f11). Paste this example for how to use the NewInspector event into the ThisOutlookSession module. You must edit the example else it would change the subjects of all of your items that you'll be opening! I don't know how to identifiy your template, if your template can be identified by its subject, the code could look like this:

Private Sub m_Inspector_Activate()

dim Item as MailItem

dim Value as string

if typeof m_Inspector.currentitem is mailitem then

set mail=m_Inspector.currentitem

if mail.subject="your template's subject" then
value=inputbox("enter the first value")

'this replaces '#0#' by the entered value

mail.body=replace(mail.body,"#0#",value)

'repeat the above two lines of code for every value.

'don't forget to change the name of the next placeholder as well

endif

endif end sub

Outlook Add-Ins & VBA Macros
www.vboffice.net

2 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 27, 2024 Views 22,316 Applies to: