New Recipient in Outlook 2011
New Recipient in Outlook 2011
- Subject: New Recipient in Outlook 2011
- From: Dave <email@hidden>
- Date: Thu, 15 Oct 2015 14:25:25 +0100
Hi,
I’m trying to add a recipient to a draft message in Outlook 2011 using AppleScript. I open the message in the drafts folder and it’s the front window when the following script runs:
on run
set myRemoveAddress to "email@hidden"
set myAddAddress to "email@hidden"
set myEmailAddressList to {}
tell application id "com.microsoft.Outlook"
activate
set myWindow to the front window
if class of myWindow is not draft window then
return "Error - Not Draft Window"
end if
save myWindow
set myObjectID to the id of (object of myWindow)
— Fails on this Line with "error "Microsoft Outlook got an error: AppleEvent handler failed." number -10000” ?????????????????????????????????????????
make new recipient at (message id myObjectID) with properties {email address:{name:"Fred Bloggs", address:myAddAddress}}
repeat with myRecipient in recipients of message id myObjectID
set myEmailAddress to email address of myRecipient
set myEmailAddressString to address of myEmailAddress as string
copy myEmailAddressString to end of myEmailAddressList
end repeat
set myRecipientCount to the number of items in myEmailAddressList
repeat with myIndex from 1 to myRecipientCount
set myEmailAddressString to item myIndex of myEmailAddressList
if myEmailAddressString starts with myRemoveAddress then
delete recipient myIndex of message id myObjectID
end if
end repeat
return "OK"
end tell
end run
I get an error on the make new recipient statement, any ideas on how to make this work would be greatly appreciated.
Thanks a lot.
All the Best
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden