Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Script Talk › Generating eMails with attachments
Tagged: attachment, email, JavaScript
- This topic has 4 replies, 2 voices, and was last updated 4 years, 11 months ago by Brendan.
-
AuthorPosts
-
November 21, 2019 at 5:44 AM #38150
EddyParticipantHi Folks!
We are using TapForms also as a CRM-System.
Therefore we let TapForms generate Emails for us. We are using a script, that generates a “mailto” phrase including address, subject and body. This headers are collected from TapForms fields. This works great.
And here is the task:
Sometimes we have to send our clients/guests a PDF (standard contract-template, checklist etc.). Of course, we store these standard PDFs in our CRM-System, i. e. TapForms. But there is no way to generate an email with an attachment by using the “mailto”-method.
What we need is a button inside a form, that creates an email with an attached file, coming out of a attached-file-field.
Any ideas?
Thanks in advance, Eddy
November 22, 2019 at 1:14 AM #38167
BrendanKeymasterThere’s no functionality for attaching a file to an email from within a Script.
However, on the iOS version, when you email a record, Tap Forms will include all photos and file attachments as attachments to the email. That functionality doesn’t exist on the Mac version though.
November 23, 2019 at 1:54 PM #38227
EddyParticipantThanks Brendan, for your promt answer!
I found a way to generate mails from Tapforms to MacOS by using Javascript.
Like this:
Mail = Application('com.apple.Mail') message = Mail.OutgoingMessage().make() message.visible = true message.toRecipients.push(Mail.Recipient({ address: "foo.bar@example.com" })) message.subject = "Testing JXA" message.content = "Foo bar baz" attachment = Mail.Attachment({ fileName: "/Users/myname/Desktop/test.pdf" }) message.attachments.push(attachment)
Or, even better by using the PATH-Command:
Mail = Application('com.apple.Mail') message = Mail.OutgoingMessage().make() message.visible = true message.toRecipients.push(Mail.Recipient({ address: "foo.bar@example.com" })) message.subject = "Testing JXA" message.content = "Foo bar baz" attachment = Mail.Attachment({ fileName: Path("/Users/myname/Desktop/if the file has spaces in it test.pdf") }) message.attachments.push(attachment)
The question is now:
How can I address the file / path inside Tapforms correctly?Thanks in advance:
Eddy
November 26, 2019 at 2:10 AM #38305
BrendanKeymasterHi Eddy,
Did you try this from within Tap Forms? I just tried, but I get
Can't find variable Application
error. I’m not sure thatApplication
is supported from within the JavaScriptCore framework.November 26, 2019 at 2:15 AM #38306
BrendanKeymasterI know where you got this from:
But that’s JavaScript for Automation. That is, from AppleScript (but using JavaScript instead of the AppleScript language).
That won’t work from within JavaScriptCore, which is what Tap Forms uses.
-
AuthorPosts
You must be logged in to reply to this topic.