1 |
Attribute VB_Name = "ModuleMailer" |
2 |
' (c) Andreas Motl <andreas.motl@ilo.de>, 2007-09-01 |
3 |
|
4 |
Option Explicit |
5 |
|
6 |
Const showProfileChooser As Boolean = True |
7 |
Const outlookProfileName As String = "" |
8 |
'Const outlookProfileName As String = "Outlook" |
9 |
'Const outlookProfileName As String = "Microsoft Exchange Server" |
10 |
Const outlookProfilePass As String = "" |
11 |
|
12 |
Public mailer As Outlook.Application |
13 |
Dim mailerAlreadyRunning As Boolean |
14 |
|
15 |
Public Function mailerCheckRunning() As Boolean |
16 |
Dim tmp As Variant |
17 |
On Error Resume Next |
18 |
tmp = mailer.ActiveExplorer.WindowState |
19 |
If Err.Number = 0 Then mailerCheckRunning = True |
20 |
On Error GoTo 0 |
21 |
End Function |
22 |
|
23 |
Public Function mailerStart() |
24 |
|
25 |
slog "creating mailer-object" |
26 |
Set mailer = New Outlook.Application |
27 |
DoEvents |
28 |
DoEvents |
29 |
|
30 |
mailerAlreadyRunning = mailerCheckRunning() |
31 |
|
32 |
If mailerAlreadyRunning Then |
33 |
slog "*not* logging on, using running mailer" |
34 |
Else |
35 |
If showProfileChooser Then |
36 |
slog "logging in (using Profile-Chooser), this may take some seconds!" |
37 |
mailer.Session.Logon , , 1 |
38 |
DoEvents |
39 |
DoEvents |
40 |
Else |
41 |
slog "logging in (auto-selecting profie " & outlookProfileName & "), this may take some seconds!" |
42 |
mailer.Session.Logon outlookProfileName, outlookProfilePass, 0 |
43 |
End If |
44 |
End If |
45 |
|
46 |
End Function |
47 |
|
48 |
Public Function mailerShutdown() |
49 |
|
50 |
slog "logging off" |
51 |
mailer.Session.Logoff |
52 |
|
53 |
If mailerAlreadyRunning Then |
54 |
slog "*not* quitting running mailer!" |
55 |
Else |
56 |
slog "closing active mail-explorer" |
57 |
mailer.ActiveExplorer.Close |
58 |
slog "quitting mailer" |
59 |
mailer.Quit |
60 |
End If |
61 |
|
62 |
slog "destroying mailer-object" |
63 |
Set mailer = Nothing |
64 |
|
65 |
End Function |