3 Replies Latest reply on Jan 20, 2015 9:27 PM by user10220526

    Html Formatted Email In Email Activity in BPEL SOA 11g


      Hi. I want to send Html formatted email using email activity . i am assigning the following expression to the contentBody variable of email.


      I email i am getting NaN. Do anybody knows how can i send formatted emails??? I am using JDEV with soa 11g bpel 1.1



        • 1. Re: Html Formatted Email In Email Activity in BPEL SOA 11g
          Martien van den Akker



          Today I worked on this myself, since I needed it on my project as well. What I did was the following.

          I created an html message as follows:

          <assign name="CreateHtmlMessageAsString">
                                  <from>concat("&lt;html&gt;&lt;body&gt;&lt;h1&gt;Reply on message  ",$umsSubject, "&lt;/h1&gt;&lt;br /&gt;Dit mailtje is &lt;em&gt;gegenereerd&lt;/em&gt;!&lt;br/&gt; Het heeft niet veel zin hier op te antwoorden.&lt;br/&gt; &lt;strong&gt;mooi he?&lt;/strong&gt;&lt;/body&gt;&lt;/html&gt;")</from>

          Then I created a bpel process to do an Base64 encode, using an embedded java. I could have done it in my main process, but this allowed me to test it seperately.

          The embedded java is as follows:


                <bpelx:exec name="B64EncodePayload" language="java">
                  <![CDATA[//Get the string from the variable 
          String htmlPayloadAsString = (String)getVariableData("htmlPayloadAsString");  
          htmlPayloadAsString = htmlPayloadAsString.replaceAll("&lt;", "<");
          htmlPayloadAsString = htmlPayloadAsString.replaceAll("&gt;", ">");
          htmlPayloadAsString = htmlPayloadAsString.replaceAll("&quot;", "\"");
          htmlPayloadAsString = htmlPayloadAsString.replaceAll("&amp;", "&");
          addAuditTrailEntry("HTML Payload is: " + htmlPayloadAsString);    
          // Encode the payload 
          Base64Encoder encoder = new Base64Encoder(); 
            String encodedString = encoder.encode(htmlPayloadAsString); 
            addAuditTrailEntry("B64 encoded string is: " + encodedString); 
            setVariableData("b64EncodedString", encodedString);
          catch(Exception e)  
            addAuditTrailEntry("Failed to encod string: " + e.getMessage() + "\nCaused by:" + e.getCause()); 
          // Set the result in the variable]]>


          You see that I do a replace of the encoded xml characters like '<', '>', '&' etc. Don't know if it's really necessary.


          I configured my email adapter to use an Opaque schema, that's why I needed to Base64 encode the string.

          The result of the base64 encoding together with the emailaddress and subject has to be assigned to the input variable as follows:

            <assign name="AssignMailProperties">
                                  <from>concat("In reply to: ", $umsSubject)</from>



          Lastly: the trick was to invoke the email service as follows:

          <invoke name="InvokeSWKOutboundEmail" partnerLink="SWKOutboundEmail" portType="ns7:SendNotification_ptt"
                                  inputVariable="InvokeSWKOutboundEmail_SendNotification_InputVariable" bpelx:invokeAsDetail="no">
                                  <bpelx:toProperty name="jca.ums.to" variable="outboundTo"/>
                                  <bpelx:toProperty name="jca.ums.subject" variable="subjectTo"/>
                                  <bpelx:toProperty name="jca.ums.msg.content-type">"text/html"</bpelx:toProperty>

          Where I gave in the property "jca.ums.msg.content-type" set to "text/html".


          Now I get Html formatted email.


          Hope this works for you.



          • 2. Re: Html Formatted Email In Email Activity in BPEL SOA 11g
            Robert van Mölken

            You are using the right function, but you are using it wrong. You are doing a concat without using the string function for that, plus sign doens't work here.



            Should be:


            <%ora:toCDATA(concat("<h2>", bpws:getVariableData('inputVariable','payload','/client:process/client:input'), "</h2>"))%>

            Hopes that does the trick.



            • 3. Re: Html Formatted Email In Email Activity in BPEL SOA 11g

              I was able to use the following tags to send the HTML formatted email correctly in SOA11g, try it out does not require any other changes.



                      <from expression="concat(string('&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml">&lt;head>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;/>&lt;/head>&lt;body>&lt;table width=&quot;800&quot; border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>&lt;tr>&lt;td height=&quot;25&quot; align=&quot;center&quot; bgcolor=&quot;#F7F7F7&quot;>&lt;font size=3 color=333399 face=Verdana> Process invalid record &lt;/td>&lt;/tr> &lt;tr>&lt;td>  &lt;/td>&lt;/tr> &lt;tr>&lt;td>&lt;font size=3 color=333399 face=Verdana>&lt;br>Invalid record updating Datebase. &lt;br>&lt;br>&lt;font size=3 color=333399 face=Verdana>The table cannot be updated in database for record-id 12345 at Date-Time: '),xp20:current-dateTime(),string(' for BPEL with Instance Id: '),ora:getInstanceId(),string('&lt;/font>&lt;/body>&lt;/html>'))"/>

                      <to variable="Invoke_emailNotification_InputVariable"