Scripting Outlook

Discussion in 'Mac Programming' started by sitryd, Mar 12, 2013.

  1. macrumors member

    Joined:
    Sep 19, 2006
    #1
    Hello all,

    I'm trying to script what I thought would be a pretty simple event in Outlook, to accept meeting requests, but the syntax doesn't appear to be doing anything. Anyone have a brilliant solution?

    Code:
    tell application "Microsoft Outlook"
    	set selectedMessages to current messages
    	if selectedMessages is {} then
    		display dialog "Please select a message first and then run this script." with icon 1
    		return
    	end if
    	
    	accept meeting sending response none
    	
    end tell
    It's not returning an error code, nor is it actually processing the selected message and accepted the invitation.
     
  2. sitryd, Mar 12, 2013
    Last edited: Mar 14, 2013

    thread starter macrumors member

    Joined:
    Sep 19, 2006
    #2
    Think I solved my own question... The following seems to work, though only from the event email (and not from a calendar event itself):

    Code:
    tell application "Microsoft Outlook"
    	set selectedMessages to selected objects
    	if selectedMessages is {} then
    		--display dialog "Please select a message first and then run this script." with icon 1
    		return
    		
    		
    	end if
    	
    	if (count of selectedMessages) is greater than 1 then
    		display dialog "Please select one meeting event for acceptance."
    	else
    		
    		repeat with theMessage in selectedMessages
    			
    			try
    				accept invite of theMessage sending response none
    			end try
    			try
    				accept meeting of theMessage sending response none
    			end try
    		end repeat
    		
    	end if
    end tell
     
  3. thread starter macrumors member

    Joined:
    Sep 19, 2006
    #3
    (Edit 2: now works with events selected in the calendar view as well as meeting invite messages)
     

Share This Page