-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhometime.cls
43 lines (35 loc) · 984 Bytes
/
hometime.cls
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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "ThisOutlookSession"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace
Dim startDate As Date
Dim workDay As Integer
Dim objTask As Outlook.TaskItem
Set Ns = Application.GetNamespace("MAPI")
Set TaskFolder = Ns.GetDefaultFolder(olFolderTasks).Items
workDay = 8 'In hours
startDate = Now
remindDate = DateAdd("h", workDay, startDate)
Set objTask = TaskFolder.Find("[Subject] ='Time to go home'")
If objTask Is Nothing Then
Set objTask = Application.CreateItem(olTaskItem)
End If
If DateDiff("d", objTask.startDate, startDate) = 0 Then
Exit Sub
End If
With objTask
.Subject = "Time to go home"
.startDate = remindDate
.ReminderTime = remindDate
.ReminderSet = True
.Body = "You arrived at work at " & startDate
.Save
End With
End Sub