Create Outlook Reminder Task using VBA code example

Create Outlook Reminder Task using VBA code example

TaskItem

Object exposes various methods and properties which can be set to create automated reminder tasks in Outlook. In this PoC we will write code to create and automated task by taking inputs from Excel sheet and mark it highly importance to the receipents.

Code example

Sub createReminderTask()
    'Outlook application object declaration
    Dim oApp As Outlook.Application
    
    'bind current outlook instance
    Set oApp = GetObject("", "Outlook.Application")
    
    
    'Declare object
    Dim oTaskItem As TaskItem
    
    'Create new item
    Set oTaskItem = oApp.CreateItem(olTaskItem)
    
    'Assign proerties
    oTaskItem.Assign
    
    'Declare Receipents object
    Dim oReceipents As Outlook.Recipient
    
    'Add receipents
    Set oReceipents = oTaskItem.Recipients.Add(Range("B2"))
    
    'Perform resolve
    oReceipents.Resolve
    
    'Check if resolved
    If oReceipents.Resolved = True Then
        oTaskItem.Subject = Range("B1")
        oTaskItem.DueDate = Range("B3")
        oTaskItem.Body = Range("B5")
    End If
    
    'Setting reminder
    oTaskItem.ReminderSet = True
    
    'Set importance
    oTaskItem.Importance = olImportanceHigh
    
    'set time
    oTaskItem.ReminderTime = Range("D3")
    
    'Start Date
    oTaskItem.StartDate = Range("B4")
    
    'Display
    oTaskItem.Display
    
    'Send
    oTaskItem.Send
    
    'Close outlook
    oApp.Quit
    
    'CleanUp
    If Not oTaskItem Is Nothing Then
        Set oTaskItem = Nothing
    End If
    
    If Not oApp Is Nothing Then
        Set oApp = Nothing
    End If
End Sub

Input

Output

Next >> Create Outlook Meeting or Appointment using VBA Code

Leave a Reply

Your email address will not be published. Required fields are marked *