Adding Subject and Body to Email

I am using the following MBS plugin to launch my user’s Apple Mail and attach a file to a new email. This works well and now I have been struggling to try to add Subject and Body information to this same email. I am wondering if I need to use an apple script, but this will be a MAS app so I wasn’t sure if that is allowed.

Call NSWorkspaceMBS.openFile(fileToAttach,"Mail",true)

If you have ideas please let me know.

Thank you much,
Mike

What if the user’s primary mail app is something other than Mail?

I have it in a Try block so it would continue. Its also a user preference to perform this function so they could opt out easily.

Is it an option to start the email, then attach the file to it?

The code above is just a way to pass file to mail.
but you could use AppleScript to modify the new message window.

Good point Kem… I assume that most OS X users use Mail.app, but i may rethink this. The email portion of this feature is to create a support ticket via an email that I would like to fill out for the user and attach a support zip file.

Christian are Apple scripts used in this capacity ok for the MAS without worrying about temporary entitlements?

Thanks!

https://forum.xojo.com/7614-using-apple-mail-with-attachment-in-sandbox/0

Add an alternative, you could create a custom page on your web site that takes this information and sends it to you. It doesn’t have to go through email at all.

Thank you for the ideas Kem I appreciate your help!

I would send it directly from your app. But some people want to review the email in mail. It’s your decision which way you go.

If you do decide to go the web site route (I would, only because of the attachment), make sure it contains some way of confirming the identify of the sender, like an RSA-encrypted key-exchange or something. It’s unlikely, but you don’t want it to become a source of spam.

ShowURL("mailto:"+emailRecipient+"?subject="+EncodeURLComponent(emailSubject)+"&body="+emailBody)

will do this, but then the attachement I don’t know how it can be done.

[quote=171782:@Massimo Valle]ShowURL("mailto:"+emailRecipient+"?subject="+EncodeURLComponent(emailSubject)+"&body="+emailBody)

will do this, but then the attachment I don’t know how it can be done.[/quote]
Thanks Massimo. Opening the email and adding the attachment and/or opening an email with Subject and Body are not the issue for me. Its doing both at the same time that seems to require apple scripting.

Thank you,
Mike

myself nor anyone I support uses Mail.app. I use AirMail, most people use Outlook for Mac (most of them came from the Windows world).

if you are going the website route, try sending the emails via Mandrill instead. It is an REST API to send the email(s). Also I have written class(es) to use Mandrill that you can use. They aren’t 100% complete as Mandrill have over 90 API calls that I have to code. And I am doing them as I have time.