简体   繁体   中英

Using AppleScript to send email with Outlook for Mac no longer works

I have an AppleScript that reads a text file that contains a list of addresses, it then creates a message for each of those address in Outlook with a subject and sends the email automatically. This has been for working for the past year or so but it's no longer working as expected. I'm not sure if this is down a recent update of Outlook or to my Mac OS. What happens now is that it will only send the address on the 1st line in the txt file.

The error message in the Results window is:

error "Can’t get every to recipient of missing value." number -1728 from every «class trcp» of missing value

In the Events window:

tell application "Microsoft Outlook"
    read "/Users/******/OneDrive/address.txt" as «class utf8»
end tell
tell current application
    read "/Users/******/OneDrive/address.txt" as «class utf8»
end tell
tell application "Microsoft Outlook"
    set the clipboard to "abuse@*****"
    make new outgoing message with properties {subject:"this is a test"}
    make new recipient with properties {email address:{address:"abuse@****"}} at end of every to recipient of outgoing message id 465175
    send outgoing message id 465175
    set the clipboard to "postmaster@*****"
    make new outgoing message with properties {subject:"this is a test"}
Result:
error "Can’t get every to recipient of missing value." number -1728 from every «class trcp» of missing value

In the Replies window:

tell application "Microsoft Outlook"
    read "/Users/******/OneDrive/address.txt" as «class utf8»
        --> error number -10004
end tell
tell current application
    read "/Users/******/OneDrive/address.txt" as «class utf8»
        --> "abuse@****
postmaster@****"
end tell
tell application "Microsoft Outlook"
    set the clipboard to "abuse@*****"
    make new outgoing message with properties {subject:"this is a test"}
        --> outgoing message id 465175
    make new recipient with properties {email address:{address:"abuse@****"}} at end of every to recipient of outgoing message id 465175
        --> to recipient 1 of outgoing message id 465175
    send outgoing message id 465175
    set the clipboard to "postmaster@*****"
    make new outgoing message with properties {subject:"this is a test"}
        --> missing value
Result:
error "Can’t get every to recipient of missing value." number -1728 from every «class trcp» of missing value

I noticed when I was looking at the AppleScript library for Outlook that I couldn't find a reference for recipients. I've also tried code from other sources online that was reported as working and testing with a single address directly in the code but I'm still getting a similar error "missing value"

My Outlook is version 16.39 (20071300) My MacOS is version 10.15.5

Here is the script, I've starred out the username on the mac for privacy; tell application "Microsoft Outlook"

set srcFile to ("/Users/******/OneDrive/address.txt") as text

set lns to paragraphs of (read srcFile as «class utf8»)
repeat with ln in lns
    set the clipboard to ln
    set theMessage to make new outgoing message with properties {subject:"this is a test"}
    make new recipient with properties {email address:{address:ln}} at end of to recipients of theMessage
    send theMessage
end repeat

end tell

Can anyone help?

Hi I have a similar problem since office update 16.39, the previous office version 16.38 works fine.

This scripts works only one time if outlook mac is closed. After the second try without closing outlook again it produces an error:

tell application "Microsoft Outlook"
    set theMessage to make new outgoing message with properties {sender:{name:"My Name", address:"demo@demo.com"}, subject:"test", plain text content:"Hallo"}
    
    tell theMessage
        make new to recipient with properties {email address:{address:"test@test.com"}}
    end tell
    send theMessage
end tell

Ergebnis: error "missing value versteht die Nachricht „make“ nicht." number -1708 from missing value

translated: "Missing value doesn't understand the make message" or "Missing value doesn't understand the make event"

I can confirm that my send mail bug is fixed with Outlook 16.41 (20072700) Insider Fast Release

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM