Clarity

  • 1.  Attachments in HTML Email

    Posted Apr 24, 2012 03:40 AM
      |   view attached
    Hi,

    Is there any way we can attach a file (stored in an attachment field) to an HTML email using GEL Script?

    I was able to get details on how to attach a file to an email from the below two threads:
    10045360
    10045723

    With the above approach im faced with two issues:
    1. The email is in plain text format, so we are not able to provide hyperlinks.
    2. The script gives the below error when i specifiy the root path (/Root/DMS/Project/sample.txt), but doent give an error when i specify it via the default filestore path. The issue with the default filestore path is that it sends the attachment with the 5million id and not with the actual file name with proper extentions. [refer attached email content]

    "An error occurred while executing custom script: org.apache.commons.jelly.JellyTagException: null:102:122: <email:email> Property 'attach' has no write method at org.apache.commons.jelly.impl.TagScript.handleException".

    Any pointer/suggestion to resolve the issue would be great. Thanks.

    PS: Save the attachment with .msg extension before opening it.

    ~Harrish

    Attachment(s)



  • 2.  RE: Attachments in HTML Email
    Best Answer

    Posted Apr 25, 2012 07:29 PM
    Hi

    I have done similar in my previous assignment. We were restarting the Clarity services automatically on weekly basis and sending the log file along with mail if Clarity Restart process fail or pass. The notification format was HTML . Refer the below code.

    <gel:script xmlns:x="jelly:xml"
    xmlns:core="jelly:core"
    xmlns:sql="jelly:sql"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
    xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
    xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xog="http://www.niku.com/xog"
    xmlns:util="jelly:util"
    xmlns:email="jelly:email"
    xmlns:file="jelly:com.niku.union.gel.FileTagLibrary">
    <util:properties file="E:/common_activities/Clarity_Restart/abc.properties" trim="true"/>
    <core:set value="${xog_url}" var="XOGURL"/>
    <core:set value="${xog_user}" var="XOGUsername"/>
    <core:set value="${xog_pwd}" var="XOGPassword"/>
    <core:set value="${support_group_email}" var="toAddress"/>
    <core:set value="${email_from}" var="fromAddress"/>
    <core:set value="${smtp_server}" var="smtpServer"/>
    <core:set value="${log_file_path}" var="log_file"/>
    <gel:formatDate format="ddMMyyyyHHmmss" stringVar="stamp"/>
    <gel:formatDate format="dd-MM-yyyy" stringVar="date"/>

    <core:catch var="xogException">
    <!--<gel:log>[XOG]Logging into Clarity Application</gel:log> -->
    <soap:invoke endpoint="${XOGURL}/niku/xog" var="auth">
    <soap:message>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
    <soapenv:Header/>
    <soapenv:Body>
    <xog:Login>
    <xog:Username>${XOGUsername}</xog:Username>
    <xog:Password>${XOGPassword}</xog:Password>
    </xog:Login>
    </soapenv:Body>
    </soapenv:Envelope>
    </soap:message>
    </soap:invoke>
    </core:catch>

    <!--CHECK THE STATUS OF Application Login for error handling -->


    <gel:set asString="true" select="$auth/soap-env:Envelope/soap-env:Body/XOGOutput/Status/@state" var="xog_output"/>



    <core:if test="${xog_output == 'FAILURE'}">


    <email:email to="${toAddress}" from="${fromAddress}" subject="Clarity Application ( ${XOGURL} ) Re-Start Failure on ${date}" server="${smtpServer}" attach="${log_file}">








    Failed to Login to the Clarity Application ( ${XOGURL} )





    Please check the Status of the Clarity Services in the attached log.






    Regards,





    Clarity Team.










    Note: This is an auto generate mail.Please do not reply to this mail.














    </email:email>





    <email:email to="${toAddress}" from="${fromAddress}" subject="Clarity Production Application is down.Please respond ASAP" server="${smtpServer}"/>


















    </core:if>



    <gel:set asString="true" select="$auth/soap-env:Envelope/soap-env:Body/XOGOutput/Status/@state" var="xog_output"/>



    <core:if test="${xog_output != 'FAILURE'}">




    <email:email to="${toAddress}" from="${fromAddress}" subject="Clarity Application ( ${XOGURL} ) Re-Started on ${date}" server="${smtpServer}" attach="${log_file}">








    Successfully Login to the Clarity Application ( ${XOGURL} )

















    Regards,





    Clarity Admin.










    Note: This is an auto generate mail.Please do not reply to this mail.














    </email:email>

















    </core:if>
    </gel:script>


    Regards,
    Shalinee


  • 3.  RE: Attachments in HTML Email

    Posted Apr 25, 2012 10:47 PM
    Thanks Shalinee for the response.

    The solution you have suggested works fine with log files. However, it doesnt work as expected when we try to send the file which is stored in the attachment field. The physical file from the attachment field is stored in encrypted form with with a 5mil ID so my final file path looks like this --> /app/clarity/filestore/file/011/231/1100349.

    Also the <email:email tag allows me to use a URL in the email, however im not sure if we can mask the URL i.e. make it as a hyperlink to the Project ID used in the email content.

    Regards,
    Harrish


  • 4.  Re: Attachments in HTML Email

    Posted Nov 29, 2016 02:14 AM

    Hi Harrish,

     

    Did you manage to handle this issue? Also we need to send file/files that/those stored in attachment filed with email. Would you mind sharing your experiences?

     

    Best regards.