I am trying to start composing a new message via mailto on OS X. I have set my default email client to be Outlook, so I can open up Outlook with a preconfigured message like so:
open 'mailto:SomeEmail#example.com?subject=hey&body=how are you doing'
but I want to also be able to use the mailto link to add an attachment to the preconfigured message. I have tried the following:
open 'mailto:SomeEmail#example.com?subject=hey&body=how are you doing&attachment=/Users/myName/Desktop/testFile.rtf'
but when Outlook opens, there is no attachment. I have read that whether or not attachments are allowed with mailto links depends on the client. Does anyone know if Outlook 2011 allows for this type of attachment?
Specifying attachments is not part of the IETF mailto: URI scheme, though individual clients may support it in one way or another.
I'm not sure if this MSDN document applies to Outlook 2011 (OSX), but if it does, then what you are trying to do is probably not possible with mailto.
Alternatively, I assume that since you are using the open command at the command-line, then you will be open to other command-line/shell-script methods of achieving this. One such way is to redirect an applescript in a bash here-document to osascript:
$ osascript <<EOF
> tell application "Microsoft Outlook"
> set myMsg to make new outgoing message with properties {subject:"hey", content:"how are you doing"}
> make new recipient at myMsg with properties {email address:{address:"SomeEmail#example.com"}}
> make new attachment at myMsg with properties {file:"/Users/myName/Desktop/testFile.rtf"}
> open myMsg
> end tell
> EOF
$
Related
So I've been using applescript with Outlook version 16 to automate some tasks. I want to create an email and then save it in the drafts folder but i've been unsuccessful.
I've tried several variations on this (like save newMessage in drafts, etc.) but can't seem to get it to work - dictionary for applescript/outlook hasn't been too helpful either. Perhaps I'm not experienced enough to understand it... I can open the email I create. I can send it from outlook. I just can't save it in drafts.
tell application "Microsoft Outlook"
set newMessage to make new outgoing message with properties {subject:"Hello I'm an email"}
set plain text content of newMessage to "Hello World "
save in drafts
end tell
I'm writing an application where I have to send an email with an attachment using the default mail application.
Before the email is sent, I want the user to be able to edit the text, i.e. the application should just open the mail client with pre-filled recipient and attachment and give the user the opportunity to send it.
At very minimum I need the same effect I'd got if I selected "SendTo/Mail Recipient" from the context menu of the file.
Solutions based on the "mailto:" trick won't work as there are mail clients that do not support the "attachment=" part.
The most complete solution I've found is this one:
http://www.codeproject.com/Articles/3839/SendTo-mail-recipient
but it seems a lot of code for something so simple! (and also crashes when compiled with VS2008)
Is there any other option? It would be ok even if it was an external tool or script (e.g. a .vbs script to be launched with cscript).
I would advise you to use MAPI (Messaging Application Program Interface).
If dotNet can be part of the solution, here's a ready-to-use class in C# : Class for creating MAPI Mail Messages. It would give you something like this:
MapiMailMessage message = new MapiMailMessage("Test Message", "Test Body");
message.Recipients.Add("Test#Test.com");
message.Files.Add(#"C:\del.txt");
message.ShowDialog();
Otherwise, you can always do it in C++ if you feel confortable with it, like this answer suggest.
Then, you will be able to ShellExecute the binary executable and pass it some parameters.
Hope this helps :-)
i'm trying to automate and simplify my life. I'm new to hazel and apple scripts..
I have a lot of documents and i pull a lot of things of the web. i simply drag the link to my desktop where it makes a .lnk file.
i want to create a hazel + apple script that will look for these .lnk files and send an email with the link file attached to my evernote email address.
Any suggestions would be appreciated.
In Hazel Create a new rule.
If all ..
1, Extension - is - ink
Do the following:
2, Run AppleScript - embedded script.
Click the info icon to edit the script. Paste this script into it. With the correct email addresses, subject, content set.
set theAttachment1 to (POSIX path of theFile)
set subject_ to "subject"
set the_content to "the_content"
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:subject_, content:the_content & return & return}
tell newMessage
set visible to false
set sender to "my1#mac.com"
make new to recipient at end of to recipients with properties {address:"their#mac.com"}
make new attachment with properties {file name:theAttachment1} at after the last paragraph
(* change save to send to send*)
send --<<<<---------------- change save to send to send or send to save to save to drafts
(* change save to send to send*)
end tell
end tell
3, Add a second action to move the file to a folder. If not you may keep getting the same files sent over and over again.
I've an application which gives Images as outputs and those outputs are to be opened in a mail client's new message [as an attachment].
On Mac OS X, Apple mail is the default mail client. So what I did was, wrote an automator workflow and opened the output in Mail.app using 'Open Finder Items' action.
Here is my problem:
If user has configured the 'Microsoft Entourage' or 'ThunderBird' or any other mail clients as their default mail client then my automator action cannot open the output in their configured mailing app.
I got some idea to find and launch the default mailing application in this link.
How do I get the default mail client using applescript?
can anyone help me how can I attach my output images to a new mail message of the launched mail client?
For the record, the accepted answer in the linked question was something like this:
tell application "System Events"
try
value of property list item "LSHandlerRoleAll" of (property list item 1 of property list item "LSHandlers" of property list file (path to preferences as text) & "com.apple.LaunchServices.plist" where value of property list items contains "mailto")
on error
"com.apple.mail"
end try
end tell
You could also use MMac::InternetConfig:
VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "mailto")[1]'
or DefaultApplication:
$ ~/bin/DefaultApplication -url mailto:
/Applications/Mail.app
I'm designing an app that allows users to email me crash reports if my app ever crashes. I'd like to leave Mac Mail running on a computer and when an email comes through, an automator script / AppleScript runs to process the contents of the body of the email.
I've got the entire parsing/processing done in a python script, except I have to manually copy the contents of the email into a file and then run my parser on that file.
What's the best way to set this up so I can the contents of the email be pushed into my parsing script?
Many thanks!
Probably the simplest approach is to define a Mail.app Rule. You can set up filtering conditions to specify the set of incoming email to apply the rule to and among the rule actions you can specify is one to run an AppleScript on incoming messages. Rules are managed with Mail.app Preferences -> Rules. Apple supplies examples of Rule Action scripts with Mac OS X. Look in /Library/Scripts/Mail Scripts/Rule Actions or search the web.
Here's a script that extracts from email into a file using a mail rule: MacScripter / Mail rule script for message export. Might be good for sample code for what you're doing.
Use the Dictionary in Applescript Editor to see the properties of mail and you'll quickly be able to see the properties of any mail message. Here's a quick and dirty example of getting the content of a mail message.
tell application "Mail"
set the_messages to selection
repeat with this_message in the_messages
set mytext to content of this_message
end repeat
end tell
Modify the script linked to above that copies output to a temporary file and then pass that file to your Python script to act on.