Private Sub cmdSendTask_Click()
Dim outlookApp As Outlook.Application
Dim outlookTask As Outlook.TaskItem
Set outlookApp = CreateObject("outlook.application")
Set outlookTask = outlookApp.CreateItem(olTaskItem)
strEmailRecipients = ""
For n = 0 To Me!lbEmail.ListCount - 1
If Me!lbEmail.Selected(n) = True Then
strEmailRecipients = strEmailRecipients & "; " & Me!lbEmail.Column(2, n) 'change 2 to column number containing the address
End If
Next n
strEmailRecipients = Mid(strEmailRecipients, 3)
With oMsg
.To = ("strEmailRecipients")
End With
With outlookTask
.Subject = "Reminder for Task: " & Me.TaskName
.Body = "This is a reminder 3 days before due. Task name: " & Me.TaskName & " is due on " & Me.DueDate
.ReminderSet = True
.DueDate = Me.DueDate
'3 days prior reminder
.ReminderTime = Me.DueDate - 3 & " 8:00AM"
ReminderPlaySound = True
.Save
End With
MsgBox "Task has been sent to Outlook successfully.", vbInformation, "Set Task Confirmed"
End Sub