• Outlook User
  • Exchange Admin
  • Office 365
  • Outlook Developer
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
    • Common Problems
    • Outlook BCM
    • Utilities & Addins

Create a Task and copy to another Tasks folder

Slipstick Systems

› Developer › Create a Task and copy to another Tasks folder

Last reviewed on January 4, 2018     2 Comments

This macro was originally written to work around an issue with the "old" Outlook.com server but now that Outlook.com is hosted on Office 365, Tasks work "as expected" and fully support attachments. However, you can use this method to copy Tasks (or with a little tweaking, other Outlook items) to another folder in your profile.

My work flow –
1) Receive an email with an attachment that I have to review
2) Create task with the attachment shortcut
3) When I’m ready to work the item I can just open the task, click on the attachment and start reviewing.
Now I have to use the create task with text, then go back to find the original email to find the attachment ….

There are two macros on this page. The first macro creates a task with a text link to the original message. This method can be used with iCloud addin to link to the original message in your mailbox. (The link will only work in Outlook, not from your iPhone.)

The second macro creates a task in a local task folder (that supports attachments) and creates a copy of the task (without the attachment) in another task folder.

Create a button on the ribbon or QAT for the macro so its easy to use.

If you have Outlook configured to set reminders on tasks with a due date, a reminder will be set. If you aren't using default reminders or want to use a different reminder, see the Set Reminder section at the end.

To create appointments instead, change each instance of TaskItem to AppointmentItem and change the field names to ones supported by appointments.

 

Create a Link to the message

A link in the body does not work with Outlook.com, due to it's lack of support for rich text bodies, so I put the link in the subject. Yes, it's ugly, but it works. You could put the link in the body, but it won't be clickable. (The code snippet at the end of this page inserts a hyperlink.)

To use this macro you need to:

  1. Set macro security to low during testing. You can sign it using selfcert later.
  2. Open VBA Editor using Alt+F11
  3. Right click on Project1 and choose Insert > Module.
  4. Paste the code into the module.
  5. Select a message, run the macro. Note: if you select more than one message, it creates a task for each message.

Sub ConvertMessagetoTask()
    Dim objTask As Outlook.TaskItem
    Dim objMail As Outlook.mailItem
    Dim strID As String
    Dim strLink, strLinkText As String

For Each objMail In Application.ActiveExplorer.Selection

    strID = objMail.EntryID
    strLink = "outlook:" & strID
    strLinkText = objMail.Subject 

Set objTask = Application.CreateItem(olTaskItem)
With objTask
    .Subject = strLinkText  & " " & strLink
    .DueDate = objMail.ReceivedTime + 3
    .StartDate = objMail.ReceivedTime + 2
    .Body = objMail.Body
    .Categories = "my category"
    .Save
End With

    Next
 
    Set objTask = Nothing
    Set objMail = Nothing
End Sub

 

Create two tasks from message

This macro creates two tasks for each selected message(s). The first task includes the original message as an attachment and saves it to a Tasks folder that supports attachments. It then creates a second task with only the message body in the task and saves it to the default Tasks folders.

In addition, the EntryID of the local task which contains the attachment is added to the Subject field (so it's clickable). This allows you to open the "attachment task" from the main task.

To use this code you need to:

  1. Set macro security to low during testing. You can sign it using selfcert later.
  2. Open VBA Editor using Alt+F11
  3. Right click on Project1 and choose Insert > Module.
  4. Paste the code below into the module.
  5. Edit the folder path for the local folder
  6. If you don't want the message body in addition to the attachment, delete that line from the first objTask code block.
  7. Uncomment the .display line if you want the task opened to add notes.
  8. Get the GetFolderPath function and paste it in the module after this macro.
  9. Select a message, run the macro. Note: if you select more than one message, it creates a task for each message.

 Sub ConvertMessagetoTwoTasks()
    Dim objTask As Outlook.TaskItem
    Dim objMail As Outlook.MailItem
    Dim newAttachment As Outlook.Attachment
    Dim strID As String
    ' Non-default folder
' Get function fromhttp://slipstick.me/qf#GetFolderPath
    Set SPSFolder = GetFolderPath("acct-name\Tasks")
 
For Each objMail In Application.ActiveExplorer.Selection
  Set objTask = Application.CreateItem(olTaskItem)
 
' Create task with message attached
' for local folder
Set newAttachment = objTask.Attachments.Add(objMail, Outlook.OlAttachmentType.olEmbeddeditem)

With objTask
    .subject = objMail.subject
    .DueDate = objMail.ReceivedTime + 3
    .StartDate = objMail.ReceivedTime + 2
    '.Body = objMail.Body
    .Categories = "MOVED"
    .Save
End With
Set MovedTask = objTask.Move(SPSFolder)
    strID = MovedTask.EntryID

Set objTask = Application.CreateItem(olTaskItem)
' create task for default folder
With objTask
    .subject = objMail.subject & " outlook:" & strID
    .DueDate = objMail.ReceivedTime + 3
    .StartDate = objMail.ReceivedTime + 2
    .Body = objMail.Body
    .Categories = "Working"
    .Save
    .Display
End With
      
    Next
    Set objTask = Nothing
    Set objMail = Nothing
End Sub

 

Set Reminders

To override your default settings for Task reminders (set in Options, Tasks), you can use the ReminderSet and ReminderTime properties.

This example creates a reminder for 6 hrs before the due date or 6 pm the day before. If a reminder time is not set, it will use the default setting for Tasks, usually 8 am on the due date.

Accepted values for ReminderSet are True (on) or False (no reminder)

objTask.ReminderSet = True
objTask.ReminderTime = objTask.DueDate - 0.25

 

Insert a hyperlink to the message

This code won't work with iCloud tasks because the link is removed from the body. If you are using it with a local task folder that does support hyperlinks, add the Dim's to the top of the code and the other lines after the End With in the first sample above.

Dim objInsp As Inspector
Dim objDoc As Word.Document
Dim objSel As Word.Selection

 Set objInsp = objTask.GetInspector
 Set objDoc = objInsp.WordEditor
 Set objSel = objDoc.Windows(1).Selection
 objDoc.Hyperlinks.Add objSel.Range, strLink, "", "", strLinkText, ""
objTask.Save

More Information

The original email-to-task code is at Create a Task from an Email using a Rule.
How to use the VBA Editor

Create a Task and copy to another Tasks folder was last modified: January 4th, 2018 by Diane Poremsky
  • Twitter
  • Facebook
  • LinkedIn
  • Reddit
  • Print

Related Posts:

  • Create Task or Appointment and Insert Selected Text
  • Create a Series of Tasks Leading up to an Appointment
  • Create a Series of Tasks using VBA
  • Create a Task from an Email using a Rule

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
2 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

John Riehl (@guest_195145)
December 6, 2015 5:32 pm
#195145

Diane,

This was fantastic...thanks. I modified it to create a new task in my PST based on a currently selected task. My particular workflow involves attaching multiple objects to a task when they're related...could be e-mails, documents, or whatever. When I have a task that I want to put an attachment into, I use this macro to automatically create the linked task.

Sub CreateLinkedAttachmentTask()
Dim objTask As Outlook.TaskItem
Dim linkTask As Outlook.TaskItem
Dim strID As String
' Non-default folder
Set SPSFolder = GetFolderPath("myPSTTasks")

For Each objTask In Application.ActiveExplorer.Selection
Set linkTask = Application.CreateItem(olTaskItem)

' create the task that will hold attachments
With linkTask
.Subject = objTask.Subject
.Body = objTask.Body
.Save
End With

' move it to the local pst and get a link to it
Set movedTask = linkTask.Move(SPSFolder)
strID = movedTask.EntryID
movedTask.Display

' update the subject of the current task with the link
With objTask
.Subject = objTask.Subject & " outlook:" & strID
.Body = "See linked task"
.Save
End With
Next

Set objTask = Nothing
Set linkTask = Nothing
End Sub

0
0
Reply
mary tanzy (@guest_183829)
June 6, 2014 10:24 am
#183829

For OneNote users, another method is to create a link to a OneNote file; the OneNote file will show the hidden attachments that you have dragged to the Task but cannot see displayed, or you can drag the attachments into the OneNote file itself. To create the link: 1. Open OneNote
2. Create a new page in the desired section (I have a Getting Things Done section for uncategorized projects and other sections for categorized projects--Vendors, Personnel), using the OneNote button in the Task tab
3. When the popup window appears prompting you to select a page to link to, select the page you have just created.

2
-2
Reply

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

Latest EMO: Vol. 28 Issue 11

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?

Subscribe to Exchange Messaging Outlook






Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • WeekMonthAll
  • Adjusting Outlook's Zoom Setting in Email
  • How to Remove the Primary Account from Outlook
  • Cannot add Recipients in To, CC, BCC fields on MacOS
  • Move an Outlook Personal Folders .pst File
  • Save Sent Items in Shared Mailbox Sent Items folder
  • Create rules that apply to an entire domain
  • Outlook's Left Navigation Bar
  • Remove a password from an Outlook *.pst File
  • Use PowerShell to get a list of Distribution Group members
  • View Shared Calendar Category Colors
  • Cannot add Recipients in To, CC, BCC fields on MacOS
  • Change Appointment Reminder Sounds
  • Messages appear duplicated in message list
  • Reset the New Outlook Profile
  • Delete Old Calendar Events using VBA
  • Use PowerShell or VBA to get Outlook folder creation date
  • Outlook's Left Navigation Bar
  • Contact's Display Bug
  • Use PowerShell to get a list of Distribution Group members
  • Edit Outlook’s Attach File list
Ajax spinner

Newest Code Samples

Delete Old Calendar Events using VBA

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

Format Images in Outlook Email

Set Outlook Online or Offline using VBScript or PowerShell

List snoozed reminders and snooze-times

Search your Contacts using PowerShell

Filter mail when you are not the only recipient

Add Contact Information to a Task

Process Mail that was Auto Forwarded by a Rule

Recent Bugs List

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

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

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.

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

Other Microsoft 365 applications and services




Windows 10 Issues

  • iCloud, Outlook 2016, and Windows 10
  • Outlook Links Won’t Open In Windows 10
  • Outlook can’t send mail in Windows 10: error Ox800CCC13
  • Missing Outlook data files after upgrading Windows?

Outlook Top Issues

  • The Windows Store Outlook App
  • The Signature or Stationery and Fonts button doesn’t work
  • Outlook’s New Account Setup Wizard
  • Outlook 2016: No BCM
  • Exchange Account Set-up Missing in Outlook 2016

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

Outlook-tips.net Samples

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

MSDN Outlook Dev Forum

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

Contact Tools

Data Entry and Updating

Duplicate Checkers

Phone Number Updates

Contact Management Tools

Diane Poremsky [Outlook MVP]

Make a donation

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

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

Outlook Suggestion Box (UserVoice)

Slipstick Support Services

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 | Advertise | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2023 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