Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

email attachment using applescript

Featured Replies

I have a solution that creates an email with an attachment.  We need to use Applescript to do this, not the default 'send mail' function, and I am having trouble getting the applescript to attach the attachment.  What is strange is that some records, it works consistently, and other records it never works.

Basically I save a PDF to the desktop, then send an applescript command to use that attachment.  The desktop PDF always creates, the new mail message always creates with the recipient pulled from the fm database, but the attachment only sometimes attaches to the message.

In FileMaker, I am setting a variable with the applescript code, then after running the applescript which calls the variable.

the variable code is as follows ...

"set theAttachment to " & Quote( $MacPosixPath & $filename )  & "¶
set RecipientAddress to " & Quote ( estimate_CLIENTCONTACT__~fkclientcontact::email1 ) & "¶
set RecipientName to " & Quote ( estimate_CLIENTCONTACT__~fkclientcontact::name_full ) & "¶


tell application \”Mail\” ¶
set newMessage to make new outgoing message with properties {visible:true} ¶


tell newMessage ¶
make new to recipient with properties {name:recipientName, address:RecipientAddress} ¶

tell content of newMessage¶
make new attachment with properties {file name:theAttachment} at after the last paragraph¶
end tell¶ 

end tell¶ 
activate ¶
end tell ¶"

 

 

The variable $MacPosixPath is defined earlier in the script as ...

Substitute ( Right ($desktopPath ;  Length ( $desktoppath) - 1 ) ; "/"; ":")

and $desktoppath is simply defined as 

Get ( DesktopPath )

 

I have attached two images to this post showing the resulting applescript that is executed.  One that works correctly and the second that does not work.  In both cases the pdf is present on the desktop.  They look identical ... stange for sure!

 

thank you in advance!

 

 

applescriptThatDidNOTWork.png

applescriptThatWorked.png

What error message is returned when you perform the second code sample from the Script Editor?

  • Author

there is never an error message, Applescript processes it correctly with no errors, just no attachment appears.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.