-
Notifications
You must be signed in to change notification settings - Fork 71
/
class_OutlookExt.ahk
141 lines (130 loc) · 3.44 KB
/
class_OutlookExt.ahk
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
class Outlook extends OfficeManager{
ExeName := ""
Outlook := ""
Mail := ""
flag := false
iqp := ""
folder := ""
sendimage := ""
__New(){
base.__New()
this.ExeName := this.p.getProperty("outlookexe")
location = %A_ScriptDir%\..\..\Lib\Properties\images.properties
i := new Properties(location)
this.sendimage := i.getProperty("OutSendmail")
this.iqp := new IQP()
}
Run(){
;this.log.Write("run outlook")
Process, Exist, % this.ExeName
If(!ErrorLevel)
{
FileWrite("|OUTLOOK| outlook wasn't running '")
this.Outlook := ComObjCreate("Outlook.Application")
this.folder := this.Outlook.GetNameSpace("MAPI").GetDefaultFolder(6)
this.folder.Display
}
Else
{
FileWrite("|OUTLOOK| outlook was running ")
this.Outlook := ComObjActive("Outlook.Application")
If !WinExist("ahk_class rctrl_renwnd32")
{
this.folder := this.Outlook.GetNameSpace("MAPI").GetDefaultFolder(6)
this.folder.Display
}
}
WinWait ahk_class rctrl_renwnd32
WinActivate, ahk_class rctrl_renwnd32
WinShow, ahk_class rctrl_renwnd32
WinMaximize ahk_class rctrl_renwnd32
}
WriteMail(recepient = "", subject = "" , body = ""){
FileWrite("|OUTLOOK| begin writting mail => recepient{" . recepient . "} subject{" . subject . "} body{" . body . "}")
this.Mail := this.Outlook.Application.CreateItem(0)
this.Mail.display
this.Mail.Recipients.Add(recepient)
this.Mail.Subject := subject
this.Mail.body := body
}
AddAttachment(location = "",filename = ""){
FileWrite("|OUTLOOK| add attachment {" location . "\" . filename . "}")
path := location . "\" . filename
this.Mail.Attachments.Add(path)
}
SendMail(){
FileWrite("|OUTLOOK| send mail ")
SetTitleMatchMode, RegEx
WinWait Message
WinActivate, Message
Sleep 500
found := false
while !found {
found := findSearchImg(A_ScriptDir . "\" . this.sendimage)
}
if(found){
clickSearchImg(A_ScriptDir . "\" . this.sendimage)
}
WinWaitClose, Message
}
SendMailWithAttachment(){
FileWrite("|OUTLOOK| send mail with attachments")
SetTitleMatchMode, RegEx
WinWait Message
WinActivate, Message
Sleep 500
while !found {
found := findSearchImg(A_ScriptDir . "\" . this.sendimage)
}
if(found){
clickSearchImg(A_ScriptDir . "\" . this.sendimage)
}
iqpoo := new IQP()
iqpoo.WaitIsReady()
Send {Enter}
WinWaitClose, Classification
}
WaitForMailBySubject(box = "", subject = "")
{
FileWrite("|OUTLOOK| waiting for mail .. ")
Inbox := this.folder
while Inbox.items(1).Subject <> subject{
Sleep 10
ToolTip wait or mail
}
FileWrite("|OUTLOOK| mail found ")
this.Mail := Inbox.items(1)
this.Mail.display
}
CloseMail(){
FileWrite("|OUTLOOK| close mail viewer ")
this.Mail.Close()
}
Close(){
FileWrite("|OUTLOOK| close Application ")
this.Outlook.Application.Quit()
WinWaitClose ahk_class rctrl_renwnd32
}
BrowseMailBySubject(box = "" , subject = "")
{
FileWrite("|OUTLOOK| looking for mail by subject {" . subject . "}")
this.flag := false
if(box = "Inbox")
Box := this.Outlook.folders(1)
for Mail in Box.items {
if (Mail.subject = subject){
this.Mail := Mail
this.flag := true
}
}
if(!flag)
MsgBox % subject . "not found"
}
;TODO verif if file exist
SaveAttachement(newname = "", location = ""){
FileWrite("|OUTLOOK| saving attachment {" . location . "\" . newname . "}")
path := location . "\" . newname
MsgBox % path
this.Mail.Attachments(1).SaveAsFile(path)
}
}