0
votes

I have an AppleScript to archive a message in Outlook 2016 for Mac. Please see below. On Outlook 2016 for Mac 16.13 (released in May 2018 via Insider Slow channel), the script fails for messages in newly added Gmail accounts when it tries to get the account of the selected message/folder (curAccount is missing value after set curAccount to account of curFolder).

This version of Outlook added support Google Calendars and Contacts and you need to remove and add Gmail account in order to get this feature. The script works fine for Exchange/Office365 accounts as well as for Gmail accounts added before the upgrade to 16.13. It fails only for newly added Gmail accounts. I guess, the Gmail integration is done differently now in this new release of Outlook 2016 for Mac.

Do you know a work-around for this issue? Do you have a script example to get a folder handle in Gmail account?

AppleScript

tell application "Microsoft Outlook"
        set currMsgs to current messages


        -- Check to make sure items are selected, if not then quit
        if (count of currMsgs) is 0 then
            display notification "No message selected" with title "Microsoft Outlook" subtitle "Move to Archive"
            return
        end if

        -- Iterate through selected items
        repeat with msg in currMsgs
            set curFolder to folder of msg
            set curAccount to account of curFolder
            if curAccount is missing value then
                display dialog ("An error occurred and the messages were not moved " & name of curFolder & " . Done") buttons {"Quit Script"} default button 1 with icon stop
                return
            end if
            set destFolder to folder "Archived" of curAccount
            move msg to destFolder
        end repeat

        --      1 Notification...
        if (count of currMsgs) is 1 then
            display notification "One message moved to " & name of curAccount & ":" & name of destFolder with title "Microsoft Outlook" subtitle "Move to Archive"
        end if

        --      Multi Notification...
        if (count of currMsgs) > 1 then
            display notification "" & (count of currMsgs) & " messages moved to " & name of destFolder with title "Microsoft Outlook" subtitle "Move to Archive"
        end if
end tell
1
Microsoft support for Outlook For Mac came back with a statement that the new gmail integration feature 'Google Preview Accounts' introduced in 16.13 does not support AppleScript. The previous gmail integration did support AppleScript. And Microsoft has not documented the issue publicly. I've posted the entire response below as an answer below, as the text size is beyond what is allowed in comments. - bravo2

1 Answers

0
votes

I received a negative response from Outlook for Mac support. Here it is. Hope it helps someone looking for an answer.

Note: This is not an answer to the question. I should have added it as a comment to the question above, but the size of text below was more than what was allowed in a comment.

Hello, I'm one of the Outlook Escalation Engineers. I understand you would like to verify and see a documentation regarding Apple Script Automation with Google Preview accounts.

I confirm Google Preview has no way to automate in Apple Script. At the moment, we have no documentation available in public regarding this. I will check what we can do about it and I will let you know. :)

I did an extra mile to submit a feature request about this through the link below. Please vote for it once it is approved and available.

Title: Give a way for Google Preview accounts to automate in Apple Script https://outlook.uservoice.com/forums/293343-outlook-for-mac/suggestions/34408744-give-way-for-google-preview-accounts-to-automate-i

I apologize for the inconvenience but we appreciate your patience and understanding.