views:

30

answers:

1

Is it possible in any way to send an email attachment through the user's default email client using AppleScript? I'm assuming there is no easy way of doing this, as the programs themselves have to implement AppleScript and every email client will implement it differently and require a different script for sending an email with an attachment.

I've searched around and only found this: http://macscripter.net/viewtopic.php?id=12463

Which can, via Applescript, give me the name of the default email client. Has anyone looked into this before?

Thank you.

+1  A: 

You are correct. You'll have to implement different applescript code for each email client. As such you'll probably want to limit the email clients your application will support and make that clear to your users.

The only other way for it to work universally is for you to implement your own email system. I have a python script that I can call from an applescript using "do shell script" to send emails. Of course you'll need to know the user's information (smtp server, username, etc). If you're interested you can see my python script here. It doesn't handle attachments but some google searching should show you how to modify it.

regulus6633
Not all email clients are AppleScriptable either, which is another problem. If you go the Python route, use Python's `email` modules to create messages with attachments. It's quite easy, e.g.: http://docs.python.org/library/email-examples.html
has
Another thought: depending on what you're trying to do, you might be able to use something other than email. e.g. If the goal is to submit registration requests or bug reports to the application developer, perhaps an HTTP(S) POST request to the developer's website would be more appropriate?
has