Pregunta

Someone at work asked me if I could implement an easy system for him to send out Outlook template-mails based on a few parameters he could enter.

An example would be a message like this:

"Hello,

Please be informed that system **Parameter1** is current down.

Regards,"

I was thinking about making a Form in Outlook VBA that would dynamically look for the amount of times a string styled like a parameter (e.g. @@parameters@@) was found in a certain template and subsequently create a editbox in the form for each found parameter.

The problem is that I obviously would like to add an box for the recipients. I would need to find a way to make the call the Outlook Addressbook and make it behave like one. This was less intuitive than I had hoped. So far I have only managed to do the following:

Dim snd As Outlook.SelectNamesDialog
Dim displayLL As Boolean

Set snd = Application.Session.GetSelectNamesDialog()
snd.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowTo
snd.AllowMultipleSelection = True
displayLL = snd.display()

As you can see, this only pops up the addressbook and allows me to select an few addresses. But I'm stumped on how I can actually make some fields that will actually act like the "To:" and "CC:" fields in a regular Outlook mail.

¿Fue útil?

Solución

Not sure how relevant this is, considering I eventually took quite a different route, but I thought I'd still add this since no-one answered.

I simply created a form that would list all templates by searching through the templates folder in the %AppData%. I would then loop through the entire mail looking for parameter-styled strings and ask for the desired value each time I would encounter such a string (through a simply inputbox). Instead of adding a custom "recipients" box, I simply opened a new mail with the parameters filled out correctly. The user could then simply add recipients to the mail like he usually would, and he was fine with this. That way, he was also able to double-check if the mail indeed looked exactly like he wanted to.

Nothing fancy or something that a 7-year old wouldn't be able to do, but it works.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top