Channel use for sending email attachments


#1

Reviewing the few mentions of channels here and in Bitbucket, all the old channel statements and functions have been brought across from P6, along with a number of modules, but currently it appears that new channel modules can’t be registered or used, and there doesn’t seem to be any channel module registration functionality built into the View Organiser as there is for custom statements.

There are three email modules in the channels that reside in PX, none supporting enclosures. Jim has suggested that he probably wouldn’t enable enclosure support himself, Dave has commented that it could be done with AppleScript in a PX procedure, and James Cook gave details of how he was able to achieve this using Python inside a PX procedure.

Even though new channel modules don’t seem to be supported, it seems to be possible to modify the code in existing modules. Would any changes made to procedures in existing modules be overwritten with new PX releases?

Or would it be better to ignore channels as Dave and James suggest?

Sending email enclosures from Panorama is a crucial feature for my business, and seems to be so for other Panorama users. It would be great to have a solid, easy to use implementation of this feature.

David Duncan


#2

We have just been able to send emails with attachments from PX using Dave’s “Email w Attachments” code plus some other code, but without accessing any channel data. This was a test of PX and AppleScript capability and needs refinement, after which I hope to use the code as a custom statement.


#3

Panorama’s channels system doesn’t support email attachments – it didn’t in Panorama 6 and still doesn’t in Panorama X. I’m not sure if it ever will or not.

For the past year or two I have been using a service called Mailgun to send emails from Panorama, including emails with attachments. This service has worked really, really well for us.

https://www.mailgun.com

I have so many projects on my plate that there is no way that I can make this available at this time. However, for those of you that are willing to do a little bit of programming and network configuration, Mailgun uses a simple HTTP interface that is very well documented. It’s pretty easy to set up with Panorama’s url( functions, or with curl. Mailgun is free for up to 10,000 emails a month so it is a pretty unbeatable deal. The trickiest part was getting the network settings configured with DKIM and SPF records so that your email doesn’t bounce as spam, but that has nothing to do with Panorama. Mailgun does have good documentation for that, though.


#4

Panorama X, as well as 6, can send email with attachments using Python. It works well and works reliably.

It’s not something that most users will find easy to set up, and it’s not soemthing I can give simple instructions for. What I will do, is make it a point to use my highly tailored process to create a generic emailer with a set of required variables to make it work for anyone.

As I currently use it, it responds intelligently to embedded graphics and attachments, including however many exist whether it be none or many. Just like any email app.


#5

Python is definitely one way to go – that’s what I used to use. What I like about mailgun is that once it is set up I found I got better results as far as emails actually being delivered and getting thru to the recipient, that is their only business and they are very good at it. (Actually, I think it is part of Rackspace so it is not really their entire business, but you get the idea.) We used to have a lot of complaints from users that weren’t receiving emails for things like order confirmations, now that has dropped to virtually zero.


#6

We use email to distribute a number of daily Panorama 6 reports (mostly PDFs) between our four factories and our national office and management. Emailing using the combination of Apple Mail channel, the SendEmail custom statement and Dave’s “Email w Attachment” channel module has been extremely reliable. We send no bulk mail and only very low volumes of mail outside the business, so I don’t think it’s necessary for us to use a service like Jim does, unless PX was not able to do what 6 had.

Fortunately it can. When we’ve finalised our PX implementation as a custom statement I’ll make it available here.

David Duncan


#7

Hi David, have you ever posted your method for sending emails with attachments in PanX? That is something that I will need to do, if possible. Thanks.


#8

I posted just such a utility for Pan X in March. See Mailbox in the Database Exchange.


#9

Tom

I don’t think that in the event I ever did — until now I’ve had response whatsoever in fact.

I have what you need to do this in PX. It’s midnight here in Sydney right now so I’ll send you this info in full sometime tomorrow when I can think clearly.

David


#10

Tom, I have the email with attachments file ready for use.

https://www.dropbox.com/s/sqx7oeeeghe4wib/EmailAttachments.pandb.zip?dl=0

I was very glad to see James Cook’s Python solution as I was always worried about Apple’s support of AppleScript. It’s great to have alternatives.


#11

David,

Thanks. That works great.
Only one issue for me: it will not work correctly if the file path has a space in a folder name. Do you think there is any way to change that behaviour?
I am sure that I can find a work around if this is not changed, so it is not a big problem.

Tom


#12

It’s been some years since I cobbled these sections of code together, but now you mention it I recall that it didn’t work if the attachment filename contained a space. I may have had the same problem with the file path, because I originally adapted the code to expect the attachment file/s to be on the desktop, and there are no spaces in that path. One of the things I did over the last couple of days to make my version of the file distributable was to enable any file path (forgetting about ones containing spaces, as you have discovered).

Looking at the original code that I borrowed, spaces are used as array separators in Attachments lists, I assume for use in AppleScript. Spaces in the parameter would definitely stuff things up.

One fix would be to require the attachment file/s to be placed on the desktop (or alternatively in the Documents folder), and reinstate the desktop (or Documents folder) as the file path leading to the attachment file/s. Do you think either would be preferable?

I’ve deleted the link to EmailAttachments file for the moment.


#13

I think you can take care of the spaces in the file path using quoted form of to convert it.

set myFilepath to quoted form of "/Users/gyonaites/Desktop/My Archive/Mail Test.scpt"

#14

HI David,

I am using the statement to send all of the files in a particular folder, each to a different person. To solve the 'spaces-in-the-path' issue, I used Panorama commands to copy the folder to a new desktop folder, send the files as attachments from there, then delete the new folder. An acceptable method, I think.  

Tom


#15

That method is ok as long as the file names themselves don’t contain spaces, only the folder names.

I think David removed the download from his DropBox, so I can’t look at the source now. But it certainly shouldn’t be difficult to fix this problem by adding quotes.


#16

I’ve reinstated the EmailAttachments.pandb file. It has better documentation and a new dropbox link:

https://www.dropbox.com/s/2pohw68pipgw7sp/EmailAttachments.pandb.zip?dl=0