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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tim LapinComputer Consultant (Desktop analyst)Commented:
No other solutions offered but the listed one should be enough to get the user going.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.