HTML question related to DD email

Hello,

I am strugling with making my e-mail looking nice… I have created a HTML version of it with the info being into tables and having colors. (not my forte )

Writing directly the color in the HTML code works. (cornsmilk background)

But I want it to be conditionnal to my DD. So I am using callContextBpmData.Character18 to hold the color info, and insert this variable into the DD e-mail.

It does not work.

So I am asking if anyone could help me construct my string properly to place into the varable in order to work.
I am assuming it is bot working because of the doublequotes.

Original code that works:

<table style="height: 47px;  background-color: cornsilk;"  border="1" width="792" cellpadding="2">

I have tried:

In my DD code: 
callContextBpmData.Character18 = "cornsmilk";
In the email code:
<table style="height: 47px;  background-color: <callContextBpmData.Character18/>;"  border="1" width="792" cellpadding="2">

Not working I think because of the double quotes…

Then I tried:

In my DD code: 
callContextBpmData.Character18 = "\"height: 47px;  background-color: cornsmilk\";";
In the email code:
<table style= <callContextBpmData.Character18/>  border="1" width="792" cellpadding="2">

Thinking placing the double quotes in my string directly… again did not work…

I am sure there is a simpler way…

Anyone could help?

Thank you

The general look is as follows:

Pierre

I don’t know if it’s the typo in your code or in the post… but you have cornsmilk in one and cornsilk in the other.

1 Like

I like to use html wrappers in my code to save myself some headache:

//Mailer Helpers
     var mailer = this.GetMailer(async: true); 
     var message = new Ice.Mail.SmtpMail();
     message.SetFrom("yourFrom@yourdomain.com");
     message.SetTo(row.Value[0].ToString());
     //message.SetCC()
     //message.SetBcc() 
     
     DateTime rawDate = (DateTime)row.Value[1];
     var trimDate = rawDate.ToShortDateString();
     string rawBody = string.Format("Quote Follow Up Date set for {0} has been reached for Quote {1} for Customer {2}.", trimDate,row.Key.ToString(), row.Value[2].ToString());
     string htmlWrapperStart = "<html><body><p>";
     string htmlWrapperEnd = "</p></body></html>";
     string finalBody = string.Format("{0}{1}{2}", htmlWrapperStart, rawBody, htmlWrapperEnd);
     
     message.SetBody(finalBody);
     message.Subject = string.Format("Follow Up Reminder: Quote {0}", row.Key.ToString());
     //Dictionary<string, string> attachments = new Dictionary<string, string>();
     //attachments.Add("MyFirstAttachment", @"\\MyServer\myFolder\MyFile.pdf");
     mailer.Send(message);

yes a typo… cornsmilk is correclty spelled
and also I noticed a semi column was not placed ok at the end, but placing it correclty did not resolve…
Pierre

This is the email widget in data directive I am using.

but it would be a plan if this way is still not working…

I created my html using a Word to HTML web tool and later replaced text with the callcontext data.

works fine.

But I am trying to dynamically change the background color of the table and it does not work…
I guess I could use your way to generate the HTML before calling the email widget… and just add the resulting string into the body…
tks…
Pierre

First off. It is “cornsilk” (without an ‘m’)
image

Neither ‘cornsmilk’ nor ‘cornmilk’ are valid
image

image

You can define CSS styles for classes, then when you dynamically build the table, insert the proper class. The end result of the message body would be like…

<html>
  <head>
    <style>
    .DD_context1 {background-color: cornsilk;}
    .DD_context2 {background-color: green;}
    </style>
  </head>
  <body>
    <table>
      <tr><th>First Name</th><th>Last Name</th><th>Points</th></tr>
      <tr class="DD_context1"><td>Peter</td><td>Griffin</td><td>$100</td></tr>
      <tr class="DD_context2"><td>Lois</td><td>Griffin</td><td>$150</td></tr>
    </table>
  </body>
</html>

edit

had to change the code from HTML to text to show up properly in post.

3 Likes

On your version you can also use the $@ notation which lets you format your HTML and interpolate variables. Example of one of my templates in a function. Makes troubleshooting life a lot easier

3 Likes

“$%”?&$%/?&%?&"!%$R"/%&/$&*"%$!

You are right… TABAR…

excuse my french!

So stupid of me that I did not look at that!
It was the issue…

Thanks Calvin!

1 Like

As I was reading down this post Is was wondering when string interpolation would be mentioned…Nice.

1 Like

download

That’s cool, never learned that before