DEV Community

Cover image for How to generate dynamic email signature when sending in D365 Marketing
rainforss
rainforss

Posted on

How to generate dynamic email signature when sending in D365 Marketing

When sending emails in D365 Marketing app, it is always a good practice to include some personalized content in the email for a special and lively touch.

Recently, a lot of clients have the requirement to take the personalization further and include an email signature of the salesperson (or marketing person). In my opinion, it is a wise move because a email signature can make the communication feel less "automated". However, do make sure that "reply-to" address points to an accessible email box in case a recipient replies to the email directly since you don't want to miss out on a customer's inquiry.

The logic of this implementation is quite simple: when sending an email to a contact during a customer journey, append the email signature of the owning user for the contact record at the end of email body. If you are no stranger to Dynamic Content, you might already have an idea of the implementation details. However, I do want to bring up one caveat of dynamic content before discussing the details of my solution.


According to Microsoft Docs -

Dynamic content gets resolved just before a message is sent to a specific individual. You'll typically use dynamic content to merge information from the recipient's contact record (such as first and last name), to place special links, and to place information and links from the content settings.

The caveat is that although you can populate dynamic content using information of records related to the recipient's contact record, you cannot traverse more than one relationship down the path from the contact table. For example, you can use a contact's parent account name to seed dynamic content because account table is directly related to contact table in D365 (only one relationship away). On the flip side, it is not feasible to use the parent account's territory information in dynamic content since territory table is only directly related to account table (two relationships away from contact table). Even if you use the dynamic content syntax like "contact.contact_account_parentcustomerid.territoryid.name", it will not resolve to the name of territory in the actual email sent. This is also specified in a Microsoft documentation:

Image description

Since my example has 3 hops (periods) in the expression, it will not resolve according to Microsoft.

What does it imply? You might be tempted to use the out-of-box table Email Signature (if you are not familiar with Email Signature, check out this amazing article by Allen Paige) to populate dynamic content for an email but it is not a viable solution since the email signature table is not directly related to the contact table. You could customize the table to add a direct one-to-many relationship to the contact table but this is very wrong, semantically. How is an email signature of a system user directly related to a contact?

To work around this impedement, we could use the first name and last name fields in combination as dynamic content but this approach falls short if you want to include additional information ,format the email signature or attach written signature pictures.

Image description

Signature with formatted text and picture

Are we stranded here? Rich text field to the rescue! When creating a new column to store text in Dataverse tables, we are given the format option of "Rich Text".

Image description

Column creation with rich text format

When "Rich text" format is chosen together with data type of "Multiple lines of text", the data stored in this field will be plain HTML and the field can be edited with rich text control when using placed on the system user table form.

Image description

Rich text editor on a form of model-driven app

When adding images using the rich text control, make sure to use the "Web Address" option instead of "From File".

Image description

Attach images with web address only

Since image uploaded to D365 will only be available in the D365 environment but not be publically accessible on the internet, resulting in broken images when recipients open the email.

Image description

Broken image since image can only be accessed within D365

Once the record is saved, the signature is stored as plain HTML which can be injected into marketing emails through dynamic content using this syntax: "contact.owninguser.hsi_emailsignature". Since emails are built with HTML behind the scene, the signature's HTML will be injected as a part of the whole HTML body, which will be rendered by email engines as user interface.

Let's perform a test send and see the final result:

Image description

I used a relatively large dimension for image here so the signature might not look appealing

Now you have learnt how to add some advanced personalization to your marketing emails, congratulations!

Top comments (0)