htmlmessage question

Not Yet Reviewed

based on a token , i would like to send a htmlmessage via email. but i see that when i use content.htmlmessage, the email output is blank.. why is this happening

below is the code snippet. it works fine with content.message, but as soon as i repalce it with content.htmlmessage, the email comes out blank.

also the content choices dont work with htmlmessage, but it works fine with content.message.

IF ($content.deviceclassification == "email")
if (exists($event.MsgSubj))
$content.subject = "["&$event.MsgLevel & "]"&" " & "("&$event.MsgCode&")"&" " &":" & $event.MsgSubj
$content.subject = "Webench Message"
@script::log("Sending email")
if ($showMessageBody)
if (exists($event.MsgText))
$content.message = $content.message & $event.MsgText & "\n"
else-if (exists($event.MsgHtml))
$content.htmlmessage = $content.htmlmessage & $event.MsgHtml & "\n" else
$content.message = $content.message & "No Message Specified" & "\n"



Date Votes

Please sign in to leave a comment.

  • Hey John,
    What does $event.MsgHtml contain? And on the blank email if you do "View Source" is there anything in the source, or is it empty? Have you tried just this:
    $content.htmlmessage = $event.MsgHtml & "\n"

    Also note that "\n" won't work in html, you'll have to use "<br/>" to insert a line break.

  • $event.MsgHtml contains a text " this is a test message" . i checked the source, its blank.
    i tired using the <br> as well, no change.

    it all works fine, if i just use content.message instead of htmlmessage..

    not able to understand what is causing this..

  • also, if i use the put another line of content.message along with content.htmlmessage in the same if statement, then i get the html email, but it comes without the content options

    else-if (exists($event.MsgHtml))
    @script::log ( $event.MsgHtml )
    $content.message = $content.message & $event.MsgText & "\n"

    $content.htmlmessage = $event.MsgHtml

  • it comes without content.choices

  • Travis, by adding a content.message before content.htmlmessage i am getting the html email now, but its missing the content.choices.

    content.choices works for content.message ,but seems missing for content.htmlmessage, any ideas how to fix this..

  • John,

    Where did you set up $content.htmlmessage?

  • Some sample code from our HP Operations Manager Unix code:

    $contentinfo = $contentinfo & "<div id=\u0022eml_param_section\u0022 class=\u0022param_section\u0022>"
    $contentinfo = $contentinfo & "<table id=\u0022eml_params\u0022 class=\u0022param\u0022 summary=\u0022Event Parameters\u0022>"
    $contentinfo = $contentinfo & "<tr id=\u0022eml_param_hdr\u0022 class=\u0022param\u0022>"
    $contentinfo = $contentinfo & "<th id=\u0022eml_param_hdr_txt\u0022 class=\u0022param\u0022 colspan=\u00222\u0022>"
    $contentinfo = $contentinfo & "HP Operations Manager (UNIX) - Automated Notification</th></tr>"
    $contentinfo = $contentinfo & "<tr id=\u0022eml_param6\u0022 class=\u0022param_even\u0022>"
    $contentinfo = $contentinfo & "<td id=\u0022eml_param_key6\u0022 class=\u0022param_key\u0022>"
    $contentinfo = $contentinfo & "Description:</td>"
    $contentinfo = $contentinfo & "<td id=\u0022eml_param_val6\u0022 class=\u0022param_val\u0022>"
    $contentinfo = $contentinfo & $event.message_text & "</td></tr>"
    $content.htmlmessage::add( $contentinfo )
    # Display response choices.
    IF ( EXISTS( $content.choices ) )
    $responseinfo = "<div id=\u0022eml_response_section\u0022 class=\u0022response_section\u0022>"

    $responseinfo = $responseinfo & "<p id=\u0022eml_response_instructions\u0022 class=\u0022instructions\u0022>"

    $size = $content.choices::size()
    IF ( $size > 0 )
    $responseinfo = $responseinfo & "Provided you can connect to the AlarmPoint Web Server, you can respond by selecting one of the following links:"
    $responseinfo = $responseinfo & "</p>"
    $responseinfo = $responseinfo & "<ol id=\u0022eml_responses\u0022 class=\u0022response\u0022 title=\u0022Response Choices\u0022>"
    $count = 0
    FOR ( $choice : $content.choices )
    # Remove Annotate from the Response Choice List for HTML Email.
    IF ( $choice != "Annotate" )
    $count = $count + 1
    $responseinfo = $responseinfo & "<li id=\u0022eml_response_item" & $count & "\u0022 class=\u0022response\u0022>"

    $responseinfo = $responseinfo & "<a id=\u0022eml_response_link" & $count & "\u0022 class=\u0022response\u0022"
    $responseinfo = $responseinfo & " href=\u0022" & $main.HTML_form_url & "?notificationId=" & $content.notification_key & "&userId=" & $userId & "&deviceType=Email&responseChoice=" & $choice & "\u0022"
    $responseinfo = $responseinfo & " title=\u0022" & $choice & "\u0022>" & $choice & "</a></li>"
    $responseinfo = $responseinfo & "</ol></div>"
    $responseinfo = $responseinfo & "<div id=\u0022eml_warning_section\u0022 class=\u0022warning_section\u0022>"
    $responseinfo = $responseinfo & "<p id=\u0022eml_warning\u0022 class=\u0022warning\u0022>"
    $responseinfo = $responseinfo & "If you are outside of the corporate network you will need to respond with the following method:"
    $responseinfo = $responseinfo & "This message is sent for informational purposes only. No response is required."
    $responseinfo = $responseinfo & "</p></div>"
    $content.htmlmessage::add( $responseinfo )

  • John, I asked Kim to join the fun as he has more experience in this department. A couple of things I see is that $content.htmlmessage is actually an array, so they do things like $content.htmlmessage::add( $contentinfo ). Also, the $content.choices is just an array and the html to display those choices must be built. So the code Kim has above iterates through the array and builds a <li> element for each entry.
    Those should get you where you need to be.

  • Pay close attention to, or copy the part after "# Display response choices.:"
    This particular code uses the value of " $content.choices" to populate the choices fields, but you could also hard code the values.

  • Sorry to be getting at this after a long time.

    ill check the suggestion by kim below.
    also is it possible to add an attachment and show it as an picture in the html email.

  • also, what this means which i found from developer guide :

    The HTML content can include forms that allow the user to submit responses back to xMatters. This functionality requires that the xMatters web server be configured with a custom JSP page to process the response.

  • Kim, i tried your code, it tries to login into web service and then acknowledge.
    i dont want to login , instead an email reply should acknowledge it..

    what i see is that if i use htmlmessage, the content.choices does not work.
    is there a way to get content.choices to work with html enabled.

  • Kim, using your code i am able to get the response choices now on the email.

    but when i click on any of the choices, it takes me to the nofiticationresponse.jsp page and then it says unsuccessful response.

    can you help me fix it.

    below is the response url for accept
    and attached is the error screenshot.

  • Could not send attachment,. however the error was

    Unsuccessful response : There was a problem handling your response; please try again later.

  • John,

    I may need to see the cocoon logs to see what went wrong
    But my bet is that the User ID is missing, so at the top of your html code put something like this:

    @person = @event::getRecipient( $recipient.owner )
    $userId = $


Didn't find what you were looking for?

New post