Question

Hyperlink within MailEvent (HTML)


Hello,


I have a little problem with the mailevent and the html body. I create a link with the anker html tag - something like this:


<a href="......?ProcessID=XXXXX">click hier</a>


Instead of XXXXX I add the processID over the k2 data browser.


The mail arrived have following content:


<a href="..ProcessID=</span>227<span style='font-family:Arial;font-size:11px;font-weight:Normal;font-style:Normal;font-stretch:Normal;color:#FF000000;text-align:Left;text-decoration:;' id='run'>"> ..."


How can I use K2 fields within HTML-Mail without any strange additional formating?


9 replies

Have you tried looking at this?


http://k2underground.com/forums/thread/23345.aspx


This might allow you to have more flexibility in your email format.

Hello,


this thread did not help me. I make something similar to this. I create a Mail Event before my Client Event and want to send an HTML Mail with some information.


I build an html code for my mail and copy it (without any LineBreaks) in the Body of the Mail Event:


<table border=0 cellspacing=0 cellpadding=10pt width=623 style="border:solid #7F7F7F 1.0pt"><tr><td align="left" valign="center" style="background:#30659a;"><span style="font-size:17.0pt;font-family:Arial,sans-serif;color:white;"><br>Workflow Notification<br></span></td></tr><tr><td><table><tr><td rowspan="4" width="200"><img src="...gif" width="87" height="83" /></td><td width="100" style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;">Process</td><td width="100" style="font-size:9.0pt;font-family:Arial,sans-serif;color:#000000;">&lt;a href="...ViewFlowMain.aspx?ProcessID=[ProcessID]">[ProcessName]</a></td></tr></tr><td style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;">Folio</td><td style="font-size:9.0pt;font-family:Arial,sans-serif;color:#000000;">[ProcessFolio]</td></tr><tr><td style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;">Customer</td><td style="font-size:9.0pt;font-family:Arial,sans-serif;color:#000000;">[Form-DisplayName]</td></tr><tr><td colspan="2" style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;">[Description]</td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td style="font-size:9.0pt;font-family:Arial,sans-serif;color:#000000;">You have tasks assigned to you. Please use the link below to action your task: <a href="..">My Worklist</a></td></tr><tr><td style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;background:#e5ecf2;height:60pt">Further information to MD-Workflows you find on the K2 [blackpearl] support side on Compass: <a href=".">Support</a></td></tr></table></td></tr></table>


Then I use the Context Browser and replace the [xxx] Parts with K2 fields.


The problem is, that this HTML-code is changed by K2 - someone, somewhere includes additional code - this additional code destroys my layout and make the used link unuseable.

I had the same issue:


http://k2underground.com/forums/thread/20860.aspx


I'm still using regular expressions to convert URLs to Hyperlinks until the Notification WYSIWYG is functional.

Hi i got this same issue also. have u found the solution yet??


 regards,


martin


man_anja:


Hello,


this thread did not help me. I make something similar to this. I create a Mail Event before my Client Event and want to send an HTML Mail with some information.


I build an html code for my mail and copy it (without any LineBreaks) in the Body of the Mail Event:


<table border=0 cellspacing=0 cellpadding=10pt width=623 style="border:solid #7F7F7F 1.0pt"><tr><td align="left" valign="center" style="background:#30659a;"><span style="font-size:17.0pt;font-family:Arial,sans-serif;color:white;"><br>Workflow Notification<br></span></td></tr><tr><td><table><tr><td rowspan="4" width="200"><img src="...gif" mce_src="...gif" width="87" height="83" /></td><td width="100" style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;">Process</td><td width="100" style="font-size:9.0pt;font-family:Arial,sans-serif;color:#000000;">&lt;a href="...ViewFlowMain.aspx?ProcessID=[ProcessID]" mce_href="...ViewFlowMain.aspx?ProcessID=[ProcessID]">[ProcessName]</a></td></tr></tr><td style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;">Folio</td><td style="font-size:9.0pt;font-family:Arial,sans-serif;color:#000000;">[ProcessFolio]</td></tr><tr><td style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;">Customer</td><td style="font-size:9.0pt;font-family:Arial,sans-serif;color:#000000;">[Form-DisplayName]</td></tr><tr><td colspan="2" style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;">[Description]</td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td style="font-size:9.0pt;font-family:Arial,sans-serif;color:#000000;">You have tasks assigned to you. Please use the link below to action your task: <a href=".." mce_href="..">My Worklist</a></td></tr><tr><td style="font-size:10.0pt;font-family:Arial,sans-serif;color:#30659a;background:#e5ecf2;height:60pt">Further information to MD-Workflows you find on the K2 [blackpearl] support side on Compass: <a href="." mce_href=".">Support</a></td></tr></table></td></tr></table>


Then I use the Context Browser and replace the [xxx] Parts with K2 fields.


The problem is, that this HTML-code is changed by K2 - someone, somewhere includes additional code - this additional code destroys my layout and make the used link unuseable.

Yes I find a solution.


I do the same as descriped (complete html-code including <html></html>) but I set the mail as "plain text". Than I go to the code and insert the IsBodyHtml Line to the SendMail code.


private void SendMail_ExecuteCode(object sender, EventArgs e)
{
SmtpClient client = new SmtpClient();
client.Host = K2.Configuration.SMTPServer;
this.EmailMessage.IsBodyHtml = true;
client.Send(
this.EmailMessage);
client =
null;


if (_emailmessage != null)
{
_emailmessage.Dispose();
}
_emailmessage =
null;
}


If you do so, you have full control of the send mail.


Regards


Anja

Hey this is Gr8, i had the same issue and resolved it by this solution and also from


http://www.k2underground.com/forums/thread/28949.aspx post.


 

I realize this is an old thread, but thought I'd give my thoughts since I see this quite often.  First, I agree that the mail event wizard needs a serious overhaul.  It should not wrap fields dragged in from the object browser within a <span> tag as it currently does.  If it simply put the text value of the field, then this would be a non-issue.  Anyway, I try not to go into the code behind of the wizards unless absolutely necessary.  The mail event is by far the most common wizard where I modify code but if the only reason I need to get to the code behind is to modify a URL format then I prefer the following approach as it is more obvious from a design perspective of what is going on:


1. Create a string variable process level data field called tempURL or something similar
2. Prior to each mail event that I need a custom URL, drop a Server Event (Code) in the activity
3. Within the server event, write code to set the tempURL data field so its string value is the hyperlink encoded string.  ex:
       <a href="http://myurl/mypage.aspx?sn=123_45&foo=1">Click here to access the form</a>
4. Within the mail event wizard, drag the tempURL data field onto the body


This approach gives me the following benefits:
1. More obvious from a design perspective that we are using custom code
2.  Removes the possibility of any custom code being deleted if someone updates the mail event's template
3.  Faster development time because constantly right-clicking the mail event and viewing code can be time consuming if Visual Studio performance is slow


I have not tested performance on this, but I would imagine that there is a slight performance hit using this approach since the custom code is in its own event rather than the mail event that gets executed anyway.  I can't imagine it being significant however.

090x will have some nifty new featues that should help with this.

I recently ran into a similar issue and I have blogged the solution I have come up with.

 

http://blogs.claritycon.com/blog/2014/10/k2-blackpearl-adding-url-links-email-message-body/

 

Hopefully this is helpful to others.

 

sVemula

Reply