Outlook 365 Help me create a Macro to make some received emails into tasks?


New Member
Outlook version
Outlook 365 32 bit
Email Account
Exchange Server
Hello, because I often miss all of the tasks I have to do I wanted to automate some things in outlook.
Every time I have to do something new I get an email in a standardized form. I would like to have a macro that automatically takes the Mail with a specific subject, copies a specific part of text (that is always in the same place) makes this the title of the task and sets the start date, the date of receiving the email and the due date to one week from receiving the email. Also nice would be that the email is attached to the task.

At the moment in the email is also a Due Date, but this is not working at the moment so there is written none at the time, but in the future it will work, and it would be nice to have the due date automatically set to the due date in the mail.

I hope someone can help me.



Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
May not be exactly what you are looking for but this should get you started. I pulled the bulk of this code from a post Diane made a while ago:

Sub ConvertEmailToTask()
''''Original Code From:
''''Create Task or Appointment and Insert Selected Text

'You need the GetCurrentItem Function from: Outlook VBA: Work with Open Item or Selected Item

Dim objTask As Outlook.TaskItem
Dim objMail As Outlook.MailItem
Dim oItem As Object

' Add reference to Word library in VBA Editor, Tools, References
Dim objWord As Word.Application
Dim objInsp As Inspector
Dim objDoc As Word.Document
Dim objSel As Word.Selection
''''Dim NewMC As

On Error Resume Next

Set objMail = GetCurrentItem()
Set objTask = Application.CreateItem(olTaskItem)

If objTask.MessageClass <> "IPM.Task.GTD Task" Then
objTask.MessageClass = "IPM.Task.GTD Task"
End If

CopyAttachments objMail, objTask

If Not objMail Is Nothing Then
If objMail.Class = olMail Then
Set objInsp = objMail.GetInspector

If objInsp.EditorType = olEditorWord Then
Set objDoc = objInsp.WordEditor
Set objWord = objDoc.Application
Set objSel = objWord.Selection
With objSel
'use wholestory to copy the entire message body

End With

End If
End If
End If

Set objInsp = objTask.GetInspector
Set objDoc = objInsp.WordEditor
Set objSel = objDoc.Windows(1).Selection

''''''''''''''''''''''CopyAttachments oItem, oTask

With objTask

'.MessageClass = "IPM.Task.GTD Task"
.Subject = objMail.Subject
'.DueDate = objMail.ReceivedTime + 3
'.StartDate = objMail.ReceivedTime + 2

objSel.PasteAndFormat (wdFormatOriginalFormatting)
'.Categories = "From Email"
' .Save

End With

'objMail.Categories = "Task" & objMail.Categories

Set objTask = Nothing
Set objMail = Nothing
Set objSel = Nothing
Set objInsp = Nothing
Set objWord = Nothing
End Sub

Sub CopyAttachments(objSourceItem, objTargetItem)

Dim fso As Object
Dim fldTemp As Object
Dim strPath As String
Dim objAtt As Attachment
Dim strFile As String

Set fso = CreateObject("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
strPath = fldTemp.Path & "\"
For Each objAtt In objSourceItem.Attachments
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
fso.DeleteFile strFile

Set fldTemp = Nothing
Set fso = Nothing
End Sub
Similar threads
Thread starter Title Forum Replies Date
P Please Help me Create a Macro ! Using Outlook 2
S HELP: Create Buttons in Outlook Email body or Tool bar Outlook VBA and Custom Forms 1
Christopher M Outlook 365 HELP! Calendar Craziness! Using Outlook 7
e_a_g_l_e_p_i Has nobody used Office 2021 enough to help me or have you given up on me.......lol Using Outlook 1
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
L Help connecting to hosted exchange server 2016 Using Outlook 0
B Seeking help with Outlook rule Using Outlook 2
D Need help with MS Authenticator Using Outlook 4
I Outlook for Mac 2019 using on desktop and laptop IMAP on both need help with folders Using Outlook 1
FryW Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
S.Champ Please help? I've imported a random workcalendar I dont even know who's. Can I undo it? and then I need to re-sync the google one again. Its a mess:( Using Outlook 2
S HTML to Plain Text Macro - Help Outlook VBA and Custom Forms 1
e_a_g_l_e_p_i Outlook 2010 Help setting up Gmail account in Outlook 2010 Using Outlook 3
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
Y Filter unread emails in a search folder vba help Outlook VBA and Custom Forms 0
L Need help modifying a VBA script for emails stuck in Outbox Outlook VBA and Custom Forms 6
F Microsoft Outlook Connector 14.0.6123.5001 - Help! Using Outlook 6
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R Disable conversation thread from replying of recipients in the same subject. Please help Using Outlook 0
R seperate read layout to design in outlook 2016..Help!! Outlook VBA and Custom Forms 3
O Help .. got lost ... installing Office like 2016 Using Outlook 5
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
Marc2019 Need help please! Cannot Setup my outlook email account on my Mac Outlook 2011 Using Outlook.com accounts in Outlook 2
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
I Help with dates in task list. Using Outlook 5
C need help setting up outlook first time Using Outlook 1
K To do bar help Using Outlook 8
M Help sending email but removing signature via VBA Outlook VBA and Custom Forms 5
S help with outlook scripting Outlook VBA and Custom Forms 4
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
EmelineGueguen Help to understand the problem of work Using Outlook 1
N Outlook Forms Help Outlook VBA and Custom Forms 2
N Need help syncing contacts to iPhone X Using Outlook 8
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
J Help! My contacts have disappeared. Using Outlook 5
J HELP- Rule to auto strip prepend from external emails Using Outlook 0
J Help Needed With Multi-Step Login Email Address Using Outlook.com accounts in Outlook 1
G Bcc help - Preventing multiple forwards from a bcc'd distribution group Using Outlook 1
G [Help] Converting array to destination folder path Outlook VBA and Custom Forms 1
K Help.... Office Outlook 2016 Using Outlook 1
S Error using AddressEntry.GetContact - need help Outlook VBA and Custom Forms 2
D Help with code to move mail on receipt to another folder based on time received Outlook VBA and Custom Forms 2
E Outlook 2010 need help with rules Using Outlook 0
B HELP! Using Outlook 4
Jeff Davis Help fix my Outlook 2013? Using Outlook 28
M Winmail. dat - HELP Using Outlook 2
Diane Poremsky Help! My Contacts are being updated! Using Outlook 0
B VBA Help Email that will save as draft and send as attachment Outlook VBA and Custom Forms 3

Similar threads