Jump to content

Attaching files to server-scheduled emails


This topic is 4817 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

This topic is 4817 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.