Conditioning email attachments

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.

Conditioning email attachments

Postby Submariner » Fri Sep 30, 2011 3:16 pm

Hi

How does one condition whether an attachment will be attached to an email or not.

I have a project whereby an SQL is run followed by a Write Excel task to convert the data to EXCEL - and then to finally send this via email as an attachment.

I would like to conditionally attach it to the email only if there is data - otherwise not.

Currently, when I run my project, the sql convert to an EXCEL produces this error if there is no data:
[8099 - Convert Ctl Grp Negative] An unexpected error occurred. Your InputStream was neither an OLE2 stream, nor an OOXML stream I can set on a variable if this error occurs and continue the next process.

Depending on the variable value, I would like to attach an attachment to the email.

Currently, the attributes for an attachment do not have the ability to condition it.

Thanks in advance
Submariner
 
Posts: 2
Joined: Fri Sep 30, 2011 2:33 pm

Re: Conditioning email attachments

Postby RElliott63 » Mon Oct 03, 2011 3:26 pm

I usually perform my Emails with the attached Job Call:

Code: Select all
<project name="Send Email" mainModule="Main" version="1.0">

   <variable name="emlHeader"   value=" " description="Project header info" />
   <variable name="emlSubject"  value=" " description="Project Subject" />
   <variable name="emlMessage"  value=" " description="Project Message" />
   <variable name="emlToList"   value=" " description="Project Email to List" />
   <variable name="emlAttach"   value=" " description="Project Attachment" />

   <module name="Main">

      <sendEmail label="Send Notification" resourceId="${emlResource}" toList="${emlToList}" version="2.0" executeOnlyIf="'${emlAttach}' eq ' '" >
         <from address="${emlFromAddress}" />
         <subject>
            <![CDATA[${emlHeader} - ${emlSubject} ]]>
         </subject>
         <message>
<![CDATA[
${emlMessage}
]]>
         </message>
      </sendEmail>       

      <sendEmail label="Send Notification" resourceId="${emlResource}" toList="${emlToList}" version="2.0" executeOnlyIf="'${emlAttach}' ne ' '" >
         <from address="${emlFromAddress" />
         <subject>
            <![CDATA[${emlHeader} - ${emlSubject} ]]>
         </subject>
         <message>
<![CDATA[
${emlMessage}
]]>
         </message>
      <attachment file="${emlAttach}" />
      </sendEmail>       

   </module>

   <description>Send an Email</description>

</project>


That way I can condition based on Successful ...

Code: Select all
        <callProject label="Notify Success" version="1.0" project="/Utilities/Send Email" runInSameJob="true" inheritUserVariables="true" returnUserVariables="true" onError="setVariable:Error=1" executeOnlyIf="( ${Error} eq 0 ) and ( '${Notify_Success}' ne '' )">
             <variable name="emlHeader"  value="${JobName} : ${JobType}" />
             <variable name="emlSubject" value="File Ready for Pickup" />
             <variable name="emlMessage" value="
File Type:  ${FileType}       ${system.carriageReturn}
File Name:  ${ThisFile:name}  ${system.carriageReturn}
                              ${system.carriageReturn}
This file is ready for transfer!" />
             <variable name="emlToList"  value="${Notify_Success}" />
          </callProject>


or Unsuccessful:

Code: Select all
        <callProject label="Notify Fail" version="1.0" project="/Utilities/Send Email" runInSameJob="true" inheritUserVariables="true" returnUserVariables="true" onError="setVariable:Error=1" executeOnlyIf="( ${Error} gt 0 ) and ( '${Notify_Fail}' ne '' )">
             <variable name="emlHeader"  value="${JobName} : ${JobType}" />
             <variable name="emlSubject" value="File Transfer Failure" />
             <variable name="emlMessage" value="
File Type:  ${FileType}       ${system.carriageReturn}
File Name:  ${ThisFile:name}  ${system.carriageReturn}
                              ${system.carriageReturn}
This file is NOT ready for transfer!  Please see previous messages for root cause." />
             <variable name="emlToList"  value="${Notify_Fail}" />
             <variable name="emlAttach"  value="${system.job.log}" />
          </callProject>



Hope this helps!

-Rick
RElliott63
 
Posts: 14
Joined: Thu Jul 01, 2010 10:42 am

Re: Conditioning email attachments

Postby Submariner » Tue Oct 04, 2011 8:10 am

Interesting concepts! Thanks. This is helpful.

Still, it would be nice in a future release to include the ability to conditionally attach the attachment based on a variable.

But I will employ this fix of yours for now.
Thx
Submariner
 
Posts: 2
Joined: Fri Sep 30, 2011 2:33 pm


Return to Community Forum

Who is online

Users browsing this forum: No registered users and 2 guests

cron