Created
June 6, 2016 08:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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