AppleScript for Outlook Mac Check Email Address Before Send

I am new at AppleScripts, and was wondering if anyone can help me with this. In Outlook 2016 for Mac I need to check if the "To", "CC", and "BCC" have internal email addresses; @internaldomain.com. If yes, than popup a message "please check email addresses". If no, than send email. Any help is greatly appreciated.
datzent83Asked:
Who is Participating?
 
Tim LapinComputer Consultant (Desktop analyst)Commented:
It turns out that recipient is both an item and a class name.  As a result, I dug deeper and found what is more likely to work:  "email address"  (do not add the quotes in your code)

Try the following changes:

 "Microsoft Outlook"   instead of   "Outlook"
email address   instead of   recipient

To read more about the above changes, open the dictionary for Microsoft Outlook and peruse its contents.  There is a lot to learn but it's all there.

Once again, I'm fairly rusty at all this so I urge you to use my code as a base from which to learn.
0
 
Tim LapinComputer Consultant (Desktop analyst)Commented:
It's been a while since I've done any serious Applescript and even longer using dictionaries of various apps but here is something that I whipped up.  I have NOT tested it but feel free to use it as a base upon which to build:


tell application Outlook
	set the_address to recipient
	set the_domain to "internaldomain.com"
	if the_address contains the_domain then
		set the_message to "Internal account"
		display dialog the_message
	else
		send
	end if
end tell

Open in new window

0
 
datzent83Author Commented:
I had to put Outlook in quotes, but then I get an error message:

tell application "Outlook"
      set the_address to recipient
      set the_domain to "internaldomain.com"
      if the_address contains the_domain then
            set the_message to "Internal account"
            display dialog the_message
      else
            send
      end if
end tell

ERROR: A class name can't go after this Identifier.

The second line is highlighted when this error pops up.
0
 
Tim LapinComputer Consultant (Desktop analyst)Commented:
No other solutions offered but the listed one should be enough to get the user going.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.