Outlook (Exchange) Attachment Stripper... Not working.

This is adapted from a working attachment stripper for mails. Has been adapted to do calendar appointments instead:


set attachmentSizeOfNote to 10000 -- this is in KB. Change this if you feel it's too small.
display dialog "Open Outlook and Select the folder (of calendar) you wish to clean. Once done, click OK to continue"
tell application "Microsoft Outlook"
	
	set thisCalendar to calendar "Calendar"
	set allmail to every calendar event of thisCalendar

	repeat with theMsg in allmail
		set msgAttachments to attachments of theMsg
		repeat with i from (count msgAttachments) to 1 by -1
			set theAttachment to item i of msgAttachments
			set theAttachmentSize to file size of theAttachment as integer
			set KSize to (theAttachmentSize / 1024)
			if KSize is greater than attachmentSizeOfNote then
				beep
				set theAttachmentName to name of theAttachment
				set results to display dialog "Do you wish to delete " & theAttachmentName & " which is " & KSize & " K big?" buttons {"Yes", "No"}
				set answer to button returned of results
				if answer is equal to "Yes" then delete theAttachment
			end if
		end repeat
	end repeat
end tell


It returns 0 events, which is not true. Any ideas?

Hi Wobbledog,
Could it be that your script isn’t referencing the correct calendar?

If I execute this snippet allmail doesn’t contain anything, of course it could be different on your mac.


tell application "Microsoft Outlook"
	set thisCalendar to calendar "Calendar"
	set allmail to every calendar event of thisCalendar
end tell

I then tried the code below to see what’s returned.


tell application "Microsoft Outlook"
	activate
	set x to every calendar
end tell

When I executed that I got a list of 3 items, or calendars.

I then used…


tell application "Microsoft Outlook"
	activate
	set x to every calendar
	set y to every calendar event of item 3 of x
end tell

… to see which calendar had some events on. I changed the item (1-3) of x each time.

From that I could work out which one I needed to reference to get a list of events.

HTH

Thanks for the reply.

Despite not being able to see any local calendars, there’s obviously one there…

Used:

tell application "Microsoft Outlook
	set thisAccount to exchange account "Mailbox - Woggledog"
	set thisFolders to calendar of thisAccount
end tell

(Available from Outlook > Preferences > Accounts… I could have done it systematically too…

This returns:

{calendar id 130 of application “Microsoft Outlook”}

So, in my script, I can now use

	set thisCalendar to calendar id 130

I did something similar yesterday, which listed two entries. I though nothing of it, actually thinking it was an error in my code, because both were called “Calendar” and had IDs of 13 an 130. It was obviously late in the day and I read both as 130.

Thank for your help…

Paul

Hi Paul,
Glad to learn you’ve sorted it.

As previously mentioned, when I tried…


tell application "Microsoft Outlook"
   activate
   set x to every calendar
end tell

… I got a list of 3 items, all called calendar.

Now working in full. In case of there being multiple accounts, it goes off and gets them for you, then, in the case of multiple calendars, it gets those too!