Workflow: Add rich HTML content in email body
One of the limitations of workflow in Microsoft Dynamics CRM 4.0 is the uncapability to add dynamic HTML content. By dynamic, I mean with data from the item that triggered the workflow.
We all know the trick of copy/paste to add static HTML in the mail but to add dynamic content is a different kettle of fish ...
In particular, I think about the following needs:
For example:
We all know the trick of copy/paste to add static HTML in the mail but to add dynamic content is a different kettle of fish ...
In particular, I think about the following needs:
- Display a table containing the information related to the current record (eg list of contacts from an account)
- Show a link to a form without displaying any url but just a clickable word
For example:
<a href="aLink">Click here</a>
will just display
Click here
In the same way, you can display HTML table with CRM content and insert it in mail body.
[UPDATE] Code example - Url builder. This code create an hypertext html control that will be used in email body. You can set a text for the hypertext control with the input property and you get back the hypertext control in output property
1: public class EntityUrlHelper : SequenceActivity
2: {
3: public static DependencyProperty linkProperty = DependencyProperty.Register("link", typeof(string), typeof(EntityUrlHelper));
4:
5: [CrmOutput("Link")] public string link
6: {
7: get
8: {
9: return (string)base.GetValue(linkProperty);
10: }
11: set
12: {
13: base.SetValue(linkProperty, value);
14: }
15: }
16: public static DependencyProperty textLinkProperty = DependencyProperty.Register("textLink", typeof(string), typeof(EntityUrlHelper));
17:
18: [CrmInput("Hypertext link text")]
19: public string textLink
20: {
21: get
22: {
23: return (string)base.GetValue(textLinkProperty);
24: }
25: set
26: {
27: base.SetValue(textLinkProperty, value);
28: }
29: }
30:
31: protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
32: {
33: IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));
34: IWorkflowContext context = contextService.Context;
35:
36: link = "<a href='http://someUrl/page.aspx?id=" + context.PrimaryEntityId.ToString() + "'>" + textLink + "</a>";
37: return ActivityExecutionStatus.Closed;
38: }
39: }
Comments
Would you happen to have an example on HT do this?
Thanks in advance,
Oliver