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.
3 posts
Page 1 of 1
- Posts: 2
- Joined: Fri Sep 30, 2011 2:33 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
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
- Posts: 14
- Joined: Thu Jul 01, 2010 10:42 am
I usually perform my Emails with the attached Job Call:
Hope this helps!
-Rick
Code: Select all
That way I can condition based on Successful ...<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>
Code: Select all
or Unsuccessful: <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>
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
- Posts: 2
- Joined: Fri Sep 30, 2011 2:33 pm
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
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
3 posts
Page 1 of 1