Skip to content

Instantly share code, notes, and snippets.

@athiyadeviyani
Created July 19, 2018 09:52
Show Gist options
  • Save athiyadeviyani/a1895c12b03c97f4faae2ef52d8072cd to your computer and use it in GitHub Desktop.
Save athiyadeviyani/a1895c12b03c97f4faae2ef52d8072cd to your computer and use it in GitHub Desktop.
Send an e-mail from MS Outlook without opening the app
-- Send a quick e-mail from your desktop without having to be distracted by all the other e-mails in your inbox!
-- by Athiya Deviyani
-- Recipient name
display dialog "Recipient name" default answer ""
set theName to text returned of result
-- Recipient e-mail address
display dialog "Recipient e-mail address" default answer "[email protected]"
set theRecipient to text returned of result
-- Subject
display dialog "Subject" default answer "No Subject"
set theSubject to text returned of result
-- Body
display dialog "Content" default answer "
"
set theContent to text returned of result
-- Attachments
display dialog "Attachments" buttons {"Choose file", "Skip"}
set btn to button returned of result
if btn is "Choose file" then
set theAttachment to (choose file)
else
set theAttachment to ""
end if
-- User can choose to either edit or send the e-mail
display dialog "Send message?" buttons {"Edit", "Send"}
set the_button to button returned of result
-- Tell Microsoft Outlook to construct the e-mail
tell application "Microsoft Outlook"
-- set the subject and body text
set newMessage to make new outgoing message with properties {subject:theSubject, content:theContent}
-- set the recipient name and e-mail address
make new recipient at newMessage with properties {email address:{name:theName, address:theRecipient}}
-- attachment handling
tell newMessage
if btn is "Choose file" then
make new attachment with properties {file:theAttachment}
end if
end tell
-- send or edit the message
if the_button is "Edit" then
open newMessage
else
send newMessage
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment