Recently I needed to update the Email Signatures for all Dynamics 365 Users and insert information from the User record.
Currently this can’t be done using the out-of-the-box solution. Even though Email Signature templates are basically email templates you are unable to insert field values like the User’s Name, Job Title and Phone Number. Therefore, to bulk update users’ signatures I needed to use code.
There are two parts to updating the Email Signature:
• Template
• Code
The Template will contain the content for each user’s Email Signature and have placeholders for user fields, which will be replaced using code.
Note: that images like email templates will need to be hosted on an internet facing website. URLs will need to be URL encoded.
When copying to the Email Signature the formatting can change, especially when copying from Microsoft Word.
To help find where the formatting has changed, use the web browser’s Developer Tools to insert the Email Signature.
Here you can edit the html within the Presentation XML.
Additional line spacing can appear as “<o:p></o:p>” or the paragraph tag, this can also be within a span.
The {full name} is within two spans with different styles, this can cause incorrect formatting. Make sure the inner span is correct, in the example the “font-size” is missing, so the outer Span’s “font-size” will be used. Also you can remove the font styling from the inner span.
The padding often adds line spacing, so removing the 4.3pt so it becomes “padding:0pt 0cm 4.3pt 0cm;” to remove the top padding.
If you copied from Word the links won’t be correct, normally the src or link to a temp location like “<v:imagedata src="file:///C:/Users/nick/AppData/Local/Temp/msohtmlclip1/01/clip_image002.png" o:title=""/>” will be removed.
Now I will cover how we can use Code to bulk update User’s Email Signatures using this Email Signature template. The Code will need to retrieve the users, then use the template to create an email signature for each user.
I used a C# Console App to run the User Email Signature update.
<emailsignature><presentationxml><table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse;"> <tbody><tr style="height:122.75pt;"> … </tbody></table></presentationxml></emailsignature>
The email signature entity schema name is “emailsignature”
The fields that need to be set are:
It is always a good idea to do a few tests to confirm the signature is created correctly.
Here is what the created template from earlier will look like for my user:
Considerations:
• Sometimes you may want to use different Email Signature depending on certain criteria.
• The email signature may need to be updated periodically, so you may want to update the existing default email signature rather than create a new email signature record.
• You don’t always want to set the Email Signature to default, sometimes users will need to review the email signature before manually setting it to the default.
• This process can be improved to retrieve and update the field more dynamically.