Create an email in Apple Mail from FileMaker

We can use our SharingService functions to share data with other applications. This includes passing styled text, containers with images, files or URLs.

Did you know we can pass styled text to Apple Mail?

Available services

Using the SharingService.ServicesForItems function, we can query the available services to request. This allows us to check which services are available and only show a button to share via Airdrop, if that is possible.

By default you have these services available on macOS:

Title Name Text File Path Images URLs
Add to Photos com.apple.share.System.add-to-iphoto - X X -
Add to Reading List com.apple.share.System.add-to-safari-reading-list - - - X
AirDrop com.apple.share.AirDrop.send - X X X
Dropbox Transfer com.getdropbox.dropbox.TransferExtension - X X -
Freeform com.apple.freeform.sharingextension X X X X
Mail com.apple.share.Mail.compose X X X X
Messages com.apple.share.Messages.window X X X X
Notes com.apple.Notes.SharingExtension X X X X
Reminders com.apple.reminders.sharingextension X X X X
Simulator com.apple.iphonesimulator.ShareExtension - X X X

If you install applications, they may offer additional services. I got Dropbox to show up here, so I included it in the table.

Send Email

Now let's send an email by sharing some text and a container with an image. The image on the right shows the Apple Mail window with styled text, but without an image.

If you don't pick a service like com.apple.share.Mail.compose, we show a menu with the plugin to pick one. For sending emails, we can pass recipients and subject lines for the email.

for the case you use email, we may predefine the subject & recipients we suggest

Set Variable [ $r ; Value: MBS("SharingService.SetEmailSubject"; "Hello") ]
Set Variable [ $r ; Value: MBS("SharingService.SetEmailRecipients"; "test@tester.test") ]

share them

Set Variable [ $r ; Value: MBS("SharingService.ShareItems";
"com.apple.share.Mail.compose";
"Dear client¶¶Hello World!";
Test::Image) ]
Set Field [ Test::Result ; $r ]

If you like to try this, please use MBS Plugin in version 15.3 with a few bug fixes in that direction. In Apple Mail, you may need to make sure the setting for new emails is set to rich text.

2 Likes

AS you mentioned Dropbox: Dropbox sounds interesting. Is it possible to use the functions offered in Dropbox context menu programmatically with your plug-in?

you can of course use the "com.getdropbox.dropbox.TransferExtension" identifier with haringService.ShareItems function.

1 Like

That's a great feature! Thank you for implementing it.

But: I have set my font size in Apple Mail to (Helvetica) 13 pt. When I create a mail using your function, the font size of the text will be 12 pt, no matter which size the field in FileMaker has been set to in layout mode. The only workaround is to set the font size of the text in the field manually to 13 pt in order to pass it to Apple Mail. A second way (not tested yet) would probably be to use the FileMaker fontsize function. But how do I know, what font size my clients use?
Is it possible to pass only the user format changes like bold, color etc. and leave the rest unchanged like FM does in Preview mode?

Well, when the plugin gets style information from FileMaker, it skips the settings of the field.

e.g. if you have 13pt text in a 13pt text field, we get no font size.
But if you change point size to 14pt in a 13pt text field, we get the size 14.

In case we have no size, we fall back to 12 if we need a size.

Maybe you should consider using 13 pt as Fallback because this is the recommended font size for body text in the Apple Human Interface Guidelines:

1 Like