-
Notifications
You must be signed in to change notification settings - Fork 7
/
MacOutlookArchive.scpt
50 lines (49 loc) · 1.63 KB
/
MacOutlookArchive.scpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
set myName to "Mac Outlook Archive"
set mailName to "Microsoft Outlook"
set inboxName to "Inbox"
set archiveName to "Archive"
tell application "Microsoft Outlook"
set frontWin to front window
set winName to name of frontWin
set currMsgs to current messages
if currMsgs = {} then
display notification ("No selected messages in window: " & winName) with title "No messages selected"
return 0
end if
set firstMsg to item 1 of currMsgs
set currAccount to account of firstMsg
set allFolders to mail folder of currAccount
set theInbox to null
repeat with theFolder in allFolders
if name of theFolder is inboxName then
set theInbox to theFolder
end if
end repeat
if theInbox is null then
display alert myName message ("Inbox folder \"" & inboxName & "\" not found") as critical
return 0
end if
try
set destFolder to folder archiveName of theInbox
on error errorMessage number errorNumber
display alert ("Archive folder not found: " & archiveName) message (errorMessage & "\nError number: " & errorNumber) as critical
return 0
end try
try
repeat with theMessage in currMsgs
set (is read) of theMessage to true
move theMessage to destFolder
end repeat
on error errorMessage number errorNumber
display alert "Archiving failed" message (errorMessage & "\nError number: " & errorNumber) as critical
return 0
end try
set msgCount to (count items in currMsgs)
if msgCount = 1 then
set msg to item 1 of currMsgs
set subj to subject of msg
display notification with title myName subtitle ("Archived: " & subj)
else
display notification with title myName subtitle ("Archived " & msgCount & " messages")
end if
end tell