I'll do my best to explain what I would like to accomplish but I have zero experience with VBA and I haven't been able to piece together anything that works.
I use Outlook 2010 and I have several different signatures. I have HTML and plain text versions of each signature so the VBA code needs to work with both types of signatures. Each signature contains an unsubscribe link. I need VBA code that can add a parameter to the unsubscribe link. The parameter being the email address of the recipient which is pulled from the TO, CC and BCC fields.
Example of the link in an HTML signature (Had to substitute curly brackets for opening and closing "a" tags):
Example of the text in a plain text signature:
I was thinking the best way would be to use a variable and have the VBA code replace the variable with the email address of each recipient.
Example:
I want to use this code so the user can click on the link and be taken to an opt-out page and have the email form filed prefilled for them.
Keep in mind that there may be more than one recipient in the TO, CC or BCC fields. I need one email per recipient with only their email address in the link.
The closest I've come is with the snippet below but it only works with HTML signatures and it uses the recipient's names instead of email addresses. It also adds all recipients to every email which is not what I want:
I was also thinking that it would be better to hash the email address with salt instead of it being past in plain text, in the URL. For example:
I can then use $_GET on the landing page and PHP to decrypt the hash and prefill the form on the unsubscribe page.
Can this be done with VBA? I haven't found any software or Outlook add-ins that can do this
Cheers,
Jeff
I use Outlook 2010 and I have several different signatures. I have HTML and plain text versions of each signature so the VBA code needs to work with both types of signatures. Each signature contains an unsubscribe link. I need VBA code that can add a parameter to the unsubscribe link. The parameter being the email address of the recipient which is pulled from the TO, CC and BCC fields.
Example of the link in an HTML signature (Had to substitute curly brackets for opening and closing "a" tags):
Code:
{a <a. href="https://www.mysite.com/opt-out/?email=user@domian.tld">href="https://www.mysite.com/opt-out/?email=[B][COLOR=#008000]user@domian.tld[/COLOR][/B]"}Unsubscribe.{/a}</a.>
Code:
Use this link to Unsubscribe: https://www.mysite.com/opt-out/?email=[B][COLOR=#008000]user@domian.tld[/COLOR][/B]
I was thinking the best way would be to use a variable and have the VBA code replace the variable with the email address of each recipient.
Example:
Code:
{a href="https://www.mysite.com/opt-out/?email=[B][COLOR=#008000]%RECIPIENT%[/COLOR][/B]"}Unsubscribe.{/a}
I want to use this code so the user can click on the link and be taken to an opt-out page and have the email form filed prefilled for them.
Keep in mind that there may be more than one recipient in the TO, CC or BCC fields. I need one email per recipient with only their email address in the link.
The closest I've come is with the snippet below but it only works with HTML signatures and it uses the recipient's names instead of email addresses. It also adds all recipients to every email which is not what I want:
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim m As MailItem
Set m = Application.ActiveInspector.CurrentItem
m.HTMLBody = Replace(m.HTMLBody, "%7b%7bRECIPIENT%7d%7d", m.To & " " & m.CC & " " & m.BCC)
End Sub
I was also thinking that it would be better to hash the email address with salt instead of it being past in plain text, in the URL. For example:
Code:
{a <a. href="https://www.mysite.com/opt-out/?email=user@domian.tld">href="https://www.mysite.com/opt-out/?email=[B][COLOR=#008000]sdfdfh53sdfg55rgfg53sg[/COLOR][/B]"}Unsubscribe.{/a}</a.>
Can this be done with VBA? I haven't found any software or Outlook add-ins that can do this
Cheers,
Jeff