Skip to content

Instantly share code, notes, and snippets.

@samdbmg
Created June 6, 2016 08:49
Show Gist options
  • Select an option

  • Save samdbmg/3de3800483a4ca8518f920cb462da30f to your computer and use it in GitHub Desktop.

Select an option

Save samdbmg/3de3800483a4ca8518f920cb462da30f to your computer and use it in GitHub Desktop.
VBA script for an Outlook rule to pick up mail with "Task: " in the subject line, and create an Outlook task from it
Sub ConvertMailToTask(Item As Outlook.MailItem)
Dim objTask As Outlook.TaskItem
Set objTask = Application.CreateItem(olTaskItem)
Dim taskSplit As New RegExp
taskSplit.Pattern = "^task[:]?\s*"
taskSplit.Global = True
taskSplit.MultiLine = True
taskSplit.IgnoreCase = True
Dim subjectString As String
If (taskSplit.Test(Item.Subject)) Then
subjectString = taskSplit.Replace(Item.Subject, "")
Else
Return
End If
objTask.Subject = subjectString
objTask.Body = Item.Body
objTask.Save
Set objTask = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment