-
Notifications
You must be signed in to change notification settings - Fork 0
/
OutlookTaskFromEmail.bas
39 lines (28 loc) · 950 Bytes
/
OutlookTaskFromEmail.bas
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
Sub CreateTaskFromEmail()
Dim objTask As Outlook.TaskItem
Dim objMail As Outlook.MailItem
Dim objSelection As Selection
' Check if the selected item is an email
Set objSelection = Outlook.Application.ActiveExplorer.Selection
If objSelection.Count = 0 Then
MsgBox "Please select an email."
Exit Sub
End If
If Not TypeOf objSelection.Item(1) Is MailItem Then
MsgBox "Please select an email."
Exit Sub
End If
Set objMail = objSelection.Item(1)
' Create a new task item
Set objTask = Application.CreateItem(olTaskItem)
With objTask
' Set the subject of the task
.Subject = objMail.Subject
' Set the start date of the task
.StartDate = objMail.ReceivedTime
' Assign the category
.Categories = "INSERT YOUR TASK CATEGORY HERE"
' Open the task window for editing
.Display
End With
End Sub