February 10, 201114 yr How can I attach a file stored in SC to an email being generated and sent using a scheduled script? I know the companion plug-in is required and I've got that setup, but I'm not sure about the rest.. Any advice would be most welcome in helping me avoid expending the time for trial and error.. TIA, Aaron
February 10, 201114 yr Use SCGetContainer to get the file you want to use as at attachment. EmailAttachFile(SCGetContainer($pathToFile))
February 11, 201114 yr Author Hmm.. Something is still amiss.. In my scheduled script I have the following: Set Variable [ $result; Value:SCSetBaseURL( RES__Resources::SC_Path ) ] Set Variable [ $attachmentPath; Value:SCGetContainer( "Email/" & Email::__kpEmailID.n) ] Send Mail [ Send via SMTP Server; No Dialog; To: $to ; CC: $cc ; BCC: $bcc ; Subject: $subject ; Message: $message ; $attachmentPath If I run though debugger, the $attachmentPath var is never declared. This seems correct since you can't store binary data in a var. Can you clarify? It could be that I'm too close to see the answer, but I've played with this a bit and I'm not having luck. The email is sent successfully, but with no attachment. Thoughts? Thanks, Aaron
February 11, 201114 yr Hmm.. Something is still amiss.. In my scheduled script I have the following: Set Variable [ $result; Value:SCSetBaseURL( RES__Resources::SC_Path ) ] Set Variable [ $attachmentPath; Value:SCGetContainer( "Email/" & Email::__kpEmailID.n) ] Send Mail [ Send via SMTP Server; No Dialog; To: $to ; CC: $cc ; BCC: $bcc ; Subject: $subject ; Message: $message ; $attachmentPath If I run though debugger, the $attachmentPath var is never declared. This seems correct since you can't store binary data in a var. Can you clarify? It could be that I'm too close to see the answer, but I've played with this a bit and I'm not having luck. The email is sent successfully, but with no attachment. Thoughts? Thanks, Aaron Hi Aaron - you're correct, I don't think it's possible to store binary data into a variable. Try using a Set Field with a global field instead of a global variable. Verify that you're actually getting the data into the container field before you try attaching it as an e-mail, so that you can separate the SuperContainer aspect of this from the e-mail aspect.
February 11, 201114 yr Author Thanks Jesse and David. I was able to get it working with some additional steps. Since you cannot export field contents with a script run from server, a global won't work. I did find, however, that I could use the SCDownload () function to download the file to a temp directory on the server. I also used the SCGetInfo () function, wrapped in a GetValue () function to grab the file name. Here's the steps: Set Variable [ $result; Value:SCSetBaseURL( RES__Resources::SC_Path ; RES__Resources::SC_Username ; RES__Resources::SC_Password )] Set Variable [ $result; Value:SCDownload( "Email" & Email::__kpEmailID.n & "/1/" ; Get ( TemporaryPath )] Set Variable [ $filename; Value:GetValue ( SCGetInfo( "Email" & Email::__kpEmailID.n ) ; 1 )] Set Variable [ $attachmentPath; Value:Get ( TemporaryPath ) & $filename ] Send Mail [ Send via SMTP Server; No Dialog; To: $to ; CC: $cc ; BCC: $bcc ; Subject: $subject ; Message: $message ; $attachmentPath] I hope this helps others.. Thanks again for your prompt replies both on and offline. Regards, Aaron
Create an account or sign in to comment