-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEMail.cls
More file actions
148 lines (119 loc) · 4.43 KB
/
EMail.cls
File metadata and controls
148 lines (119 loc) · 4.43 KB
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
142
143
144
145
146
147
148
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "EMailClass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'Deze module bevat de Microsoft Outlook gerelateerde procedures.
Option Explicit
Private WithEvents EMail As Outlook.MailItem 'Bevat een verwijzing naar een Microsoft Outlook e-mailbericht.
Attribute EMail.VB_VarHelpID = -1
Private WithEvents MSOutlook As Outlook.Application 'Bevat een verwijzing naar Microsoft Outlook.
Attribute MSOutlook.VB_VarHelpID = -1
'Deze procedure beheert de Microsoft Outlook statusinformatie.
Private Function OutlookReedsActief(Optional NieuweOutlookReedsActief As Variant) As Boolean
On Error GoTo Fout
Static HuidigeOutlookReedsActief As Boolean
If Not IsMissing(NieuweOutlookReedsActief) Then HuidigeOutlookReedsActief = CBool(NieuweOutlookReedsActief)
EindeProcedure:
OutlookReedsActief = HuidigeOutlookReedsActief
Exit Function
Fout:
If HandelFoutAf(VraagVorigeKeuzeOp:=False) = vbIgnore Then Resume EindeProcedure
If HandelFoutAf() = vbRetry Then Resume
End Function
'Deze procedure voegt de opgegeven geëxporteerde queryresultaten toe aan een e-mail.
Public Sub VoegQueryResultatenToe(Optional ExportPad As Variant = vbNullString, Optional ExportPaden As Collection = Nothing)
On Error GoTo Fout
If Not (EMail Is Nothing Or MSOutlook Is Nothing) Then
If ExportPaden Is Nothing Then
EMail.Attachments.Add ExportPad
Else
For Each ExportPad In ExportPaden
If Not ExportPad = vbNullString Then EMail.Attachments.Add ExportPad
Next ExportPad
End If
If Instellingen().ExportAutoVerzenden Then EMail.Send
End If
EindeProcedure:
Exit Sub
Fout:
If HandelFoutAf(VraagVorigeKeuzeOp:=False) = vbIgnore Then Resume EindeProcedure
If HandelFoutAf() = vbRetry Then Resume
End Sub
'Deze procedure stelt deze module in.
Private Sub Class_Initialize()
On Error GoTo Fout
OutlookReedsActief NieuweOutlookReedsActief:=False
Set MSOutlook = New Outlook.Application
If Not MSOutlook Is Nothing Then
Set EMail = MSOutlook.CreateItem(olMailItem)
EMail.GetInspector.Activate
End If
EindeProcedure:
Exit Sub
Fout:
If HandelFoutAf(VraagVorigeKeuzeOp:=False) = vbIgnore Then Resume EindeProcedure
If HandelFoutAf() = vbRetry Then Resume
End Sub
'Deze procedure wordt uitgevoerd wanneer deze module wordt afgesloten.
Private Sub Class_Terminate()
On Error GoTo Fout
Set EMail = Nothing
Set MSOutlook = Nothing
EindeProcedure:
Exit Sub
Fout:
If HandelFoutAf(VraagVorigeKeuzeOp:=False) = vbIgnore Then Resume EindeProcedure
If HandelFoutAf() = vbRetry Then Resume
End Sub
'Deze procedure wordt uitgevoerd wanneer een nieuwe e-mail wordt geopend.
Private Sub EMail_Open(Cancel As Boolean)
On Error GoTo Fout
With Instellingen()
If Not EMail Is Nothing Then
EMail.Body = VervangSymbolen(.EMailTekst)
EMail.CC = .ExportCCOntvanger
EMail.SentOnBehalfOfName = .ExportAfzender
EMail.Subject = VervangSymbolen(.ExportOnderwerp)
EMail.To = .ExportOntvanger
End If
End With
EindeProcedure:
Exit Sub
Fout:
If HandelFoutAf(VraagVorigeKeuzeOp:=False) = vbIgnore Then Resume EindeProcedure
If HandelFoutAf() = vbRetry Then Resume
End Sub
'Deze procedure wordt uitgevoerd wanneer een e-mail wordt afgesloten.
Private Sub EMail_Unload()
On Error GoTo Fout
If Not (Instellingen().QueryAutoSluiten Or OutlookReedsActief()) Then
If Not MSOutlook Is Nothing Then
MSOutlook.GetNamespace("MAPI").Logoff
MSOutlook.Quit
End If
End If
EindeProcedure:
Exit Sub
Fout:
If HandelFoutAf(VraagVorigeKeuzeOp:=False) = vbIgnore Then Resume EindeProcedure
If HandelFoutAf() = vbRetry Then Resume
End Sub
'Deze procedure wordt uitgevoerd wanneer Microsoft Outlook wordt gestart.
Private Sub MSOutlook_Startup()
On Error GoTo Fout
OutlookReedsActief NieuweOutlookReedsActief:=True
EindeProcedure:
Exit Sub
Fout:
If HandelFoutAf(VraagVorigeKeuzeOp:=False) = vbIgnore Then Resume EindeProcedure
If HandelFoutAf() = vbRetry Then Resume
End Sub