How to set sender in Outlook POP account using AppleScript? - outlook

This script selects my main account and the signature related to it.
tell application "Microsoft Outlook"
set theContent to "Mail Content etc."
set theMessage to make new outgoing message with properties {subject:(("Month ") & (do shell script "date '+%m'")), content:theContent}
make new recipient with properties {email address:{address:"to#mail.com"}} at end of to recipients of theMessage
make new recipient with properties {email address:{address:"to#mail.com"}} at end of cc recipients of theMessage
open theMessage
end tell
I would like to add a line that picks one of several POP accounts to send from.
Ideally the resulting mail has the signature stored under that address.

Related

Select mailbox for Microsoft Outlook when using Applescript

I'm using Applescript to automatically draft and send emails in Microsoft Outlook. While everything is working as expected to send emails from my own account, I want to adjust the script to send emails from a different account that I have access to in Outlook. I've found this post, but the approach shown there generates an error for me.
https://macscripter.net/viewtopic.php?pid=185222#p185222
How can I adjust the script below to select the correct mailbox to send my email from? When I use the script below, the following error is generated when I attempt to save it.
Syntax Error
Expected class name but found identified
I've Google this error message, but haven't been able to find anything relevant to my task of changing the account the email is sent from.
set theAccount to the first exchange account whose name is "second.account#company.com"
set recipientAddress to "first.last#company.com"
set theSubject to "This is only a test"
set theContent to "<html><body><p>This is only a test.</p></body></html>"
tell application "Microsoft Outlook"
set newMessage to make new outgoing message with properties {account:theAccount, subject:theSubject, content:theContent}
tell newMessage
make new recipient at newMessage with properties {email address:{address:recipientAddress}}
end tell
save in drafts
end tell

MacOS. How to programmatically check a new SMS message?

I want to periodically programmatically check whether a new SMS message has arrived from a specific sender. If it came, then I want to copy text the text to the clipboard.
using terms from application "Messages"
on message received theMessage from theBuddy for theChat with eventDescription
set the clipboard to theMessage
end message received
end using terms from

How to add an attachment to an email reply with AppleScript

The code below allows me to create an email reply:
tell application "Mail"
set theAttachmentFile to "path"
set theMessages to the selected messages of the front message viewer
set theMessage to first item of theMessages
set theOutgoingMessage to reply theMessage with opening window and
reply to all
end tell
in this situation I'm not able to add an attachment file to the replay front message. In what way can i do that? Is it possible?
Thanks!

choosing mail account in applescript

I'd like to send a mail using a Mac Automator action. I prepared the following mail script:
set recipientName to "<recipient>"
set recipientAddress to "<recipient mail address>"
set theSubject to "<mail subject>"
set textBody to "<text>"
tell application "Mail"
set theMessage to make new outgoing message with properties {subject:theSubject, content:textBody, visible:true}
--set recipient
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
--send the message
send
end tell
end tell
now when I send this it uses the Account that is basically currently selected (highlighted) in the Mail App.
Is there any way to choose a specific account?
You need to set the sender of theMessage to a valid address of one of your accounts.
e.g.
set recipientName to "<recipient>"
set recipientAddress to "<recipient mail address>"
set theSubject to "<mail subject>"
set textBody to "<text>"
set theSender to "dragon5689#stackoverflow.com" -- your valid account email here
tell application "Mail"
set theMessage to make new outgoing message with properties {subject:theSubject, content:textBody, visible:true, sender:theSender}
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
send
end tell
end tell

Get contents of iChat message via Applescript

I'll preface this with the fact that I'm new to applescript...
I have iChat set up to run this script whenever a new message is received:
using terms from application "iChat"
on message received theMessage from theBuddy for theChat
set theHandle to handle of theBuddy
tell application "MyApp"
receivedInstantMessage from theHandle message theMessage
end tell
end message received
end using terms from
This works as expected an MyApp (which I'm coding) receives two strings (the handle of the buddy and the message content). The only trouble is that this script only seems to work once at least one message has been received in iChat. I.e the script seems to only work from the second message onwards. If the buddy logs out, he'll have to send two messages again before my app receives the AppleEvent.
Am I making a basic mistake here?
The first message is actually a "text invitation" so your notification script will need another handler:
on received text invitation theMessage from theBuddy for theChat
-- your tell app statement goes here
end received text invitation

Resources