Solved how to Send Mail with collection table in message body??

venugopalreddy

New Member
Dear All,

1) I am not able to send mail with collection table in message body along with some predefined text <(placed in variables)> ,
Could you please help me to sort it out..!!
If its required to code stage please provide code plz.
2) How can i convert collection table to text format-- if its possible...??
If its required to code stage please provide code plz.

Thanks & Regards,
Gopal.
 

sheel

New Member
string textBody = "<table cellpadding='5' cellspacing='0' style='border: 1px solid #ccc;font-size: 9pt;font-family:Arial'><tr><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Scenario No</th><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Scenario Detail</th><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Scenario Status</th><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Comment</th></tr>";
for (int loopCount = 0; loopCount < Collection_In.Rows.Count; loopCount++)
{
if(Collection_In.Rows[loopCount][3] == "")
{
textBody += "<tr><td style='border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][0] + "</td><td style='border: 1px solid #ccc'> " + Collection_In.Rows[loopCount][1] + "</td><td style='color: #32CD32;border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][2] + "</td><td style='border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][3] + "</td></tr>";
}
else
{
textBody += "<tr><td style='border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][0] + "</td><td style='border: 1px solid #ccc'> " + Collection_In.Rows[loopCount][1] + "</td><td style='color: #FF0000;border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][2] + "</td><td style='color: #FF0000;border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][3] + "</td></tr>";
}

}
textBody += "</table>";
Email_String = textBody;
=======================
Collection_In input in code stage
Email_String output in code stage
 

venugopalreddy

New Member
string textBody = "<table cellpadding='5' cellspacing='0' style='border: 1px solid #ccc;font-size: 9pt;font-family:Arial'><tr><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Scenario No</th><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Scenario Detail</th><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Scenario Status</th><th style='background-color: #B8DBFD;border: 1px solid #ccc'>Comment</th></tr>";
for (int loopCount = 0; loopCount < Collection_In.Rows.Count; loopCount++)
{
if(Collection_In.Rows[loopCount][3] == "")
{
textBody += "<tr><td style='border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][0] + "</td><td style='border: 1px solid #ccc'> " + Collection_In.Rows[loopCount][1] + "</td><td style='color: #32CD32;border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][2] + "</td><td style='border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][3] + "</td></tr>";
}
else
{
textBody += "<tr><td style='border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][0] + "</td><td style='border: 1px solid #ccc'> " + Collection_In.Rows[loopCount][1] + "</td><td style='color: #FF0000;border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][2] + "</td><td style='color: #FF0000;border: 1px solid #ccc'>" + Collection_In.Rows[loopCount][3] + "</td></tr>";
}

}
textBody += "</table>";
Email_String = textBody;
=======================
Collection_In input in code stage
Email_String output in code stage
Dear Sheel,

I hope it will work, thank you so much for your response.

Regards,
Gopal.
 

RobertJ

New Member
It is not necessary to have a code stage.
Start your email body with table tags and a heading if needed like--

<table style = 'border-bottom: 1px solid black; border-bottom-style: collapse;' >
<tr style = 'border-bottom: 1px solid black; padding: 10px;'>
<tr>
<th style = 'border-bottom: 1px solid black; padding: 10px;'> Name </th>
<th style = 'border-bottom: 1px solid black; padding: 10px;'> Emp. ID </th>
<th style = 'border-bottom: 1px solid black; padding: 10px;'> </th>
<th style = 'border-bottom: 1px solid black; padding: 10px;'> </th>
</tr>


Then just loop through the collection and have a calculation object to insert the data into a line such as

"<td style = 'border-bottom: 1px solid black; padding: 10px;' >" & [Collection.Column1] & "</td>" & NewLine() &
"<td style = 'border-bottom: 1px solid black; padding: 10px;' >" & [Collection.Column1] & "</td>" & NewLine() &
"<td style = 'border-bottom: 1px solid black; padding: 10px;' >" & "</td>" & NewLine() &
"<td style = 'border-bottom: 1px solid black; padding: 10px;' >" & "</td>" & NewLine()

Then append this to the email text.
 
Hello,
just a quick question ... the code above works for me but with one loop and one calculation , it always update the data item with the current row collection ... how can I append data to get all three lines of the collection?
Thanks.
 

RobertJ

New Member
Attached is the process. Use the loop construct from the tool box to access every item in the collection. The second block of code I provided above is in the "Format New Line" calculation, then the "Append Line" takes the calculation result and adds it to the main body of the email text.
 

Attachments

  • Loop through Collection.png
    8.5 KB · Views: 24
Top