• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Create Tasks from Email and move to different Task folders

Slipstick Systems

› Developer › Code Samples › Create Tasks from Email and move to different Task folders

Last reviewed on August 29, 2018     45 Comments

This macro is the result of a question from a "Getting Things Done" user who wanted a better way to manage tasks on his smartphone.

I use the GTD method and I’ve found that assigning categories doesn’t work for me, one reason is I like to sync the tasks to my iPhone. When you just assign categories and dump everything in one big bucket you have to constantly expand and collapse your views to isolate the right group – lots of clicking and mouse moving. I want to select a message from my inbox – then click on a macro button and have it copied to the appropriate task folder – Do It Today, Deferred, etc. It would look like just like the buttons in the Quick Steps, but unfortunately they just assign the category. I found Create a Task from an Email using a Rule but need help making it work.

Copy the following code block, one copy for each Task folder, and replace the Sub name and folder name (in tFolder) with the name of the folder it will apply to.

Sub TasksFoldername()
tFolder = "Old Tasks"
CreateTasks
End Sub

Create QAT or ribbon buttons for the folder macros. To do this, go to File, Options, Customize Ribbon (or Quick Access Toolbar). In Choose commands from, select Macros. Select the folder macros and click the Add button to add them to the QAT or a ribbon. (If using the ribbon, you need to add a New Group first.)

Tip: if you use the QAT, you can assign keyboard shortcuts to the macros.

Create tasks from email

To use, you need the GetCurrentItem function from Outlook VBA: work with open item or selected item. This will allow the code to work with open or selected messages.

Public tFolder As String

Private Sub CreateTasks()
      
Dim Ns As Outlook.NameSpace
Dim olTask As Outlook.TaskItem
Dim Item As Outlook.mailItem

Set Ns = Application.GetNamespace("MAPI")

' Get Function athttp://slipstick.me/e8mio
Set Item = GetCurrentItem()

Set taskFolder = Ns.GetDefaultFolder(olFolderTasks).Folders(tFolder)
Set olTask = taskFolder.Items.Add(olTaskItem)
With olTask
        .Subject = Item.Subject
        .Attachments.Add Item
        .Body = Item.Body
        .DueDate = Now + 1
        .Save
        .Display 'show the task to add notes
End With
Set Ns = Nothing
End Sub

' create one macro for Tasks each folder
' add to ribbon or QAT button
Sub TasksFoldername1()
tFolder = "My Tasks"
CreateTasks
End Sub

Sub TasksFoldername2()
tFolder = "Old Tasks"
CreateTasks
End Sub

How to use the macros on this page

First: You need to have macro security set to the lowest setting, Enable all macros during testing. The macros will not work with the top two options that disable all macros or unsigned macros. You could choose the option Notification for all macros, then accept it each time you restart Outlook, however, because it's somewhat hard to sneak macros into Outlook (unlike in Word and Excel), allowing all macros is safe, especially during the testing phase. You can sign the macro when it is finished and change the macro security to notify.

To check your macro security in Outlook 2010 and newer, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, look at Tools, Macro Security.

After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

Macros that run when Outlook starts or automatically need to be in ThisOutlookSession, all other macros should be put in a module, but most will also work if placed in ThisOutlookSession. (It's generally recommended to keep only the automatic macros in ThisOutlookSession and use modules for all other macros.) The instructions are below.

The macros on this page should be placed in a module.

Open the VBA Editor by pressing Alt+F11 on your keyboard.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

More information as well as screenshots are at How to use the VBA Editor

More Information

  • Automatically create a task when sending a message
  • Create a Task from an Email using a Rule
  • Create an Outlook Appointment from a Message
  • Create Task or Appointment and Insert Selected Text
  • Create Tasks from Email and move to different Task folders
  • Replicate GTD: Create a task after sending a message
Create Tasks from Email and move to different Task folders was last modified: August 29th, 2018 by Diane Poremsky

Related Posts:

  • Create a Task and copy to another Tasks folder
  • Create a Series of Tasks using VBA
  • Create a Task from an Email using a Rule
  • Create a Series of Tasks Leading up to an Appointment

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
45 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Michael (@guest_199644)
June 28, 2016 6:59 am
#199644

Hi Diane

I have the following which is working fine:
Sub ConvertMailtoTask(Item As Outlook.MailItem)
Dim objTask As Outlook.TaskItem
Set objTask = Application.CreateItem(olTaskItem)
With objTask
.Subject = Item.Subject
.StartDate = Item.ReceivedTime
.Body = Item.Body
.Save
End With
Set objTask = Nothing
End Sub

However I would like it to save the tasks to the task folder of another exachange account that is shared. the other folder is also named "Tasks" (Being the default Task folder for that account.

How do I tell it to save the tasks to the other default task folder?

Thanks in advance
Michael

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Michael
June 28, 2016 11:40 pm
#199664

Use this to add to other folders -
Set objTask = olTaskFolder.Items.Add(olTaskItem)

to identify the folder olTaskFolder represents, see https://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/#shared for the code to identify a shared exchange folder. If the account is open in the profile (as an account), you can use the GetFolderPath function on that page.

0
0
Reply
Dan P (@guest_196957)
March 4, 2016 12:02 am
#196957

Hello Diane,

I am using Outlook 2013. I have attempted to implement the above code but for some reason every time I run it I get the comment "The attempted operation failed. An object could not be found."

Running the debugger shows the following code line highlighted:
Set taskFolder = Ns.GetDefaultFolder(olFolderTasks).Folders(tFolder)

Could you please help me understand how to fix this? I cannot figure it out. I have ensured all my macro settings are appropriate for testing.

Cheers

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Dan P
March 6, 2016 11:43 pm
#197002

This line: Set taskFolder = Ns.GetDefaultFolder(olFolderTasks).Folders(tFolder) at a subfolder under your default tasks folder. The actual folder name is set in the variable tFolder, using one of these macros. If you don't have folders under the task folder with those names and want to use the default task folder, use Set taskFolder = Ns.GetDefaultFolder(olFolderTasks)

' create one macro for Tasks each folder
' add to ribbon or QAT button
Sub TasksFoldername1()
tFolder = "My Tasks"
CreateTasks
End Sub

Sub TasksFoldername2()
tFolder = "Old Tasks"
CreateTasks
End Sub

0
0
Reply
John Z (@guest_193258)
September 11, 2015 12:13 pm
#193258

Hello Diane,
Thank you for the truly excellent post.

I would like to modify the approach you have on saving the item as an attachment and do the following.

Copy the item body into the task body ( you already do this)
Copy the item attachments to the task as task attachments. ( you attach the original email as an attachment.

My goal is to make the task a mirror copy of the original email (including attachment) without having to open the Item to find the original attachments. Can it be done?

0
0
Reply
David Bell (@guest_195262)
Reply to  John Z
December 11, 2015 10:47 am
#195262

Is there someone I can pay to help me with this? I enjoy the topic but don't have time to learn it.

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  David Bell
December 11, 2015 11:07 am
#195264

I offer training and assistance for $100/hour. You just wanted the attachments added to the task or did you need other things too?

0
0
Reply
Nikhil (@guest_193150)
September 6, 2015 1:49 pm
#193150

Dear Diane,

Thanks once again for all the help. May be I am getting too creative, but is it possible that I can create two simulatenous tasks at the same time from the same email? I would like one task to be created in the 'Projects' task folder and another in the 'Next Action' folder - both originating from the same email.

Thanks in advance.
Nikhil

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Nikhil
September 6, 2015 5:21 pm
#193160

Sure, just repeat these lines, replacing tfolder with the actual folder name
Set taskFolder = Ns.GetDefaultFolder(olFolderTasks).Folders(tFolder)
Set olTask = taskFolder.Items.Add(olTaskItem)
With olTask
.Subject = Item.Subject
.Attachments.Add Item
.Body = Item.Body
.DueDate = Now + 1
.Save
.Display 'show the task to add notes
End With

1
0
Reply
Nikhil (@guest_195636)
Reply to  Diane Poremsky
December 25, 2015 1:20 am
#195636

Diane,

Hope you are doing great. I wanted a few minor tweaks to the code. Please let me know if it is possible.
1.) Can I choose Due Date to be a specific day for e.g. this week Friday or next week Monday?
2.) I am struggling to add the option where the task once created, gets auto-emailed to my Evernote account. You had shared the below link, but it seems to be for a new email. I am looking to forward the task i am creating.
https://www.slipstick.com/developer/create-a-new-message-using-vba/

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Nikhil
December 28, 2015 1:30 am
#195659

1. Yes, you just need to calculate the date.
use this as the date -
.DueDate = Format(dteFriday(Now()), "mm/dd/yy")
and this function - change the formulas for Monday.

Public Function dteFriday(dte As Date) As Date
Dim x As Integer
x = Weekday(dte)
Debug.Print x
If x = 7 Then
dteFriday = dte - 1 + x
Else
dteFriday = dte + 6 - x
End If
End Function

2. do you want to send it as an attachment or as text in the body? this will send it as an attachment and with notes in the body. Add it after the End with that creates the task.
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)

With objMsg
.To = "Alias@domain.com"
.Subject = olTask.Subject
.Body = olTask.Subject & vbCrLf & olTask.DueDate
.Attachments.Add olTask
.Display
End With

0
0
Reply
Nikhil (@guest_200208)
Reply to  Diane Poremsky
July 24, 2016 2:09 pm
#200208

Dear Diane,

I tried using the code to choose Friday as the default date. I copied the public function too. I am getting a syntax error. Could you please see if I am missing something?

0
0
Reply
Nikhil (@guest_192723)
August 19, 2015 8:55 am
#192723

Dear Diane,

Thanks a lot for the help and special thanks for bearing with my really basic knowledge. The workflow is working exactly as I wanted. Is there a way I can:

1.) Add a step where the task also gets emailed (to my Evernote or ToodleDo account) while it is being created in one of the customized folders?

2.) I can hide the default 'Task' and 'To-Do' folders, so that only my customized folders remain visible.

Thanks once again. You are amazing.

Nikhil

0
0
Reply
Nikhil (@guest_192824)
Reply to  Nikhil
August 23, 2015 2:23 pm
#192824

Thanks Diane in advance for considering my above query.

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Nikhil
August 23, 2015 11:47 pm
#192828

1. Sure. Do you want to send it as a task request or as an email containing task information? See https://www.slipstick.com/developer/create-a-new-message-using-vba/ for sample code that creates a message.

2. You can start in Tasks or only show tasks in the To-Do list but you can't hide them - outlook will unhide them.
See https://www.slipstick.com/outlook/tasks/remove-todo-list-tasks-list-outlook/ to start in tasks

0
0
Reply
Nikhil (@guest_192570)
August 14, 2015 4:33 am
#192570

Thanks Diane.

Truly appreciate your help. The code is working perfectly!
Is there a modification possible where the task saves the email as an attachment and doesn't copy the email text? I am seeing it is doing both. I can see the email text and email as an attachment.

Also, if the customized folder isn't a sub-folder within the default Tasks folder, what would be the modification?

Thanks in advance. You are amazing.

Nikhil

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Nikhil
August 14, 2015 7:05 pm
#192592

these lines do the body and attachment - delete one or both
.Attachments.Add Item
.Body = Item.Body

this handles the folder -
Set taskFolder = Ns.GetDefaultFolder(olFolderTasks).Folders(tFolder)
if ts at the same level as tasks, you'd use
Set taskFolder = Ns.GetDefaultFolder(olFolderTasks).parent.Folders(tFolder)

0
0
Reply
Nikhil (@guest_192521)
August 13, 2015 10:15 am
#192521

Diane - I will appreciate your help on the above. I know I am asking a lot of basic questions and am truly grateful for your patience.

0
0
Reply
Nikhil (@guest_192429)
August 9, 2015 8:41 am
#192429

Thanks Diane. I am copying the code below I am trying. I have created a sub-folder within Tasks called 'Test1'. I am getting a compile error 'Expected End Sub'. 'Private Sub CreateTasks () is getting yellow highlighted.

Thanks a lot in advance. You are super helpful.

Private Sub CreateTasks()

Dim Ns As Outlook.NameSpace
Dim olTask As Outlook.TaskItem
Dim Item As Outlook.MailItem

Set Ns = Application.GetNamespace("MAPI")

Function GetCurrentItem() As Object
Dim objApp As Outlook.Application

Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select

Set objApp = Nothing
End Function
Set Item = GetCurrentItem()

Set taskFolder = Ns.GetDefaultFolder(olFolderTasks).Folders(tFolder)
Set olTask = taskFolder.Items.Add(olTaskItem)
With olTask
.Subject = Item.Subject
.Attachments.Add Item
.Body = Item.Body
.DueDate = Now + 1
.Save
.Display 'show the task to add notes
End With
Set Ns = Nothing
End Sub

' create one macro for Tasks each folder
' add to ribbon or QAT button
Sub TasksFoldername1()
tFolder = "Test1"
CreateTasks
End Sub

1
-1
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Nikhil
August 13, 2015 3:30 pm
#192538

This part goes at the end of the macros or in a different module (other macros can use it too).
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application

Set objApp = Application
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
End Select

Set objApp = Nothing
End Function

1
-1
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 15

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Disable "Always ask before opening" Dialog
  • Adjusting Outlook's Zoom Setting in Email
  • This operation has been cancelled due to restrictions
  • Remove a password from an Outlook *.pst File
  • Reset the New Outlook Profile
  • Maximum number of Exchange accounts in an Outlook profile
  • Save Attachments to the Hard Drive
  • How to Hide or Delete Outlook's Default Folders
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
  • Use PowerShell to Delete Attachments
  • Remove RE:, FWD:, and Other Prefixes from Subject Line
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Newest Code Samples

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment