I have two email signatures. I use an internal signature for all
firstname.lastname@example.org recipients, and an external signature for all
email@example.com. At this moment, the default signature is the internal one. If I want to use the external one, I can manually set it in the ribbon.
I wondered if there was any possibility to let Outlook 365 automatically change the signature if he detects that the addressee email address does not belong to the company.
The 'Apply rule on messages I send' is only able to apply an action after the message has been sent (see following 2 images). But I would need it to be activated after I have entered the addressees.
The answer is no. You'll need to come up with some sort of custom solution or look for a third party app to help. I looked around a bit and didn't really find any solution I would recommend. Another route would be to look at smaller marketing integration tools - these may let you compose messages and send them with select signatures based on "campaign" - just assign certain users to the campaign and messages you generate will get the footer (or whatever else) you want to inject.
Back to a possible coding option
There is a forum string here that may help ( https://social.msdn.microsoft.com/Forums/en-US/9cfedfdf-b7a8-442d-96b8-a5cf5a149673/adding-outlook-signature-using-ole-automation?forum=isvvba ).
They use the below to get access to signature files.
shell = new ActiveXObject("WScript.shell"); user_name = shell.ExpandEnvironmentStrings("%USERNAME%"); fso = new ActiveXObject("Scripting.FileSystemObject"); signatureTextStream = fso.OpenTextFile("C:\\Documents and Settings\\" + user_name + "\\Application Data\\Microsoft\\Signatures\\" + user_name + "." + file_ext, 1); signatureContents = signatureTextStream.ReadAll(); signatureTextStream.Close();
If you combine that with logic to read the recipients - you may be able to get a working solution for your self.
Sub GetSMTPAddressForRecipients(mail As Outlook.MailItem) Dim recips As Outlook.Recipients Dim recip As Outlook.Recipient Dim pa As Outlook.PropertyAccessor Const PR_SMTP_ADDRESS As String = _ "http://schemas.microsoft.com/mapi/proptag/0x39FE001E" Set recips = mail.Recipients For Each recip In recips Set pa = recip.PropertyAccessor Debug.Print recip.name & " SMTP=" _ & pa.GetProperty(PR_SMTP_ADDRESS) Next End Sub
If I get some time - I will try and put this together in a working solution, but if anyone else were to post it for you that would be great too. Otherwise hopefully this get's you down the right path.
External links referenced by this document: