Create Task from Email and put body & email as attachment into task notes

Status
Not open for further replies.

azhumvee

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Using Outlook 2010... So as far as converting emails to tasks.. outlook only has option to move or copy an email with Text **OR** Attachment, but I want both. Is this possible with a macro? - sorry, day 1 of macros here :(

I still want the subject of the email carried over as the temporary Subject of the task (and leaving the cursor there to make changes to it)

Next, would it be possible to then (after creating the associated task) - also perform a particular Quick Step (by name of the quick step) ? I just want to be able to move the email to a folder out of the inbox, and maybe toss a category on it too...

So I have Developer in my ribbon.. i click on macros.. name one, create it.. i now have VBA with a Sub macroname()

End Sub


after I paste the code, I'll hit debug - Project1 ? Hope i'm on the right track. Thank you so much everyone. You are all amazing from what I've seen posted here.. TIA!
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I have a run a script sample at http://www.slipstick.com/outlook/rules/create-task-email-rule/ - you can set the task subject to be the mail subject but the cursor isn't left in the subject field. It can be converted to a macro you run on demand, there is a sample macro at the bottom of the page.

Michael will correct me if i'm wrong, but as far as I know, quick steps are not available to be automated, so you can't call one from a macro. You could build the same steps into a macro. Adding a category to the original email and moving it is not a big deal.

See http://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/ for basics on using the editor, but yeah, that is basically what you do.
 

azhumvee

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Michael - thank you, i'm aware of the follow-up feature.. i just don't like the fact the flags/follow-ups don't appear in any mobile form of outlook access.. and the main reason i dont want to use those - i cant have the fields that exist only in tasks (notes, % complete etc.)

Diane - thanks.. would it indeed be possible to do both though thru a macro/vba? that is - Move an email to create a new task with attachment and text of the message? Ideally I would want to select an entire existing email conversation (top level of hierarchy) and push a macro button and have it move all the emails as separate attachments and include the full summary of all the text in the notes section of a new task.. essentially clearing my inbox of that conversation, and then i work with it (and reply as needed) strictly from a task view... hope this makes sense

I will have to find someone to code this for me. :( however, i did successfully implement and use the code from the sample macro at the bottom of your create-task-email-rule page... its just a start of what i want to build. :)

do you know of anyone on these forums that would take $ or a donation to build little GTDish macro codes for me?
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
That's possible with a macro except there's no selection if you just select the header of the conversation.

If you have usual $$/hour in mind when you think of "donation", I could help you.
 

azhumvee

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Thank you.. Well as it turned out i've muddled up the concept of what I was trying to do.. one small problem.. I wanted the embedded email to be ABOVE the body in the task notes area... i'm thinking thats impossible.. am I right? heres the code

Sub MoveSelectedMailtoTask()
Dim objTask As Outlook.TaskItem
Dim objMail As Outlook.MailItem

Set objTask = Application.CreateItem(olTaskItem)

For Each objMail In Application.ActiveExplorer.Selection

With objTask
.Subject = objMail.Subject
.StartDate = objMail.ReceivedTime
.Body = vbCrLf + vbCrLf + objMail.Body
objMail.SaveAs attPath & objMail.EntryID
objTask.Attachments.Add attPath & objMail.EntryID, olEmbeddeditem
Kill (attPath & objMail.EntryID)
.Display
End With
objMail.Delete
Next
Set objTask = Nothing
Set objMail = Nothing
End Sub
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Attachments.Add has more paramters, one is for the position.
 

azhumvee

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
I put
objTask.Attachments.Add attPath & objMail.EntryID, olEmbeddeditem, 1

and it basically ignores the position.. still puts it at after the body..
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Despite the description mentioned by Diane, it does work here for task items in Outlook 2007, and 2010. I canot tell you why it shouldn't work for you.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I see the same thing as azhumvee, using Outlook 2013. While it should work for Tasks because they are rich text, it's not working for me.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
I didn't try it but maybe it's due to the very long EntryID file name?
 

azhumvee

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Michael, I'll try that theory when I get home.. didn't want to start a new thread but I have a similar section of vba code and I want this to behave a little differently.. But I'm having problems of course... i want this one to take an email i have selected, move it to a prespecified folder (test folder below the inbox in this example).. then create a task with body of email & embedded original email .. ignoring the position of the embedded item for now.. for whatever reason I get a "the operation failed" message.. I'm assuming it's because the EntryID changes when email is moved to a different folder.. is there a way to have my code below first move it, get the entryID of the new location, THEN create a task all in one macro? code as follows:


Sub MoveToFiled()
Dim ns As Outlook.NameSpace
Dim moveToFolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Dim objTask As Outlook.TaskItem
Dim objMail As Outlook.MailItem

Set ns = Application.GetNamespace("MAPI")
'Define path to the target folder
Set moveToFolder = ns.GetDefaultFolder(olFolderInbox).Folders("test")
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox ("No item selected")
Exit Sub
End If
If moveToFolder Is Nothing Then
MsgBox "Target folder not found!", vbOKOnly + vbExclamation, "Move Macro Error"
End If
'For Each objItem In
Set objItem = Application.ActiveExplorer.Selection(1)
If moveToFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move moveToFolder
Else
MsgBox "wrong type of item"
Exit Sub
End If
End If
'Next
Set objTask = Application.CreateItem(olTaskItem)
'For Each objMail In Application.ActiveExplorer.Selection
With objTask
.subject = objItem.subject
.StartDate = objItem.ReceivedTime
.Body = vbCrLf & vbCrLf & "url:eek:utlook:" & objItem.EntryID & vbCrLf + objItem.Body
objItem.SaveAs attPath & objItem.EntryID
objTask.Attachments.Add attPath & objItem.EntryID, olEmbeddeditem
Kill (attPath & objItem.EntryID)
.Display
End With
'objMail.Delete
'Next
Set objItem = Nothing
Set moveToFolder = Nothing
Set ns = Nothing
Set objTask = Nothing
Set objMail = Nothing
End Sub
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
The Move function returns the new, moved item. Set the variable to it, then the new EntryID will be available.
 

azhumvee

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
Thanks Michael.. wow i actually figured it out on my own.. :)

last question (I think!) for this topic... can I make the url outlook entry id link have a name so it doesnt have to show a 80 to 100 or whatever character link to the entryID? but instead just an alias/name for the link? like a clickable "Original Message"
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Really on your own? If our suggestions are wrong, and you've found another solution, post it so others can benefit.

For the url the message must be in html format. See in an html documentation how to use the <a> tag.
 

azhumvee

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server 2010
no, misunderstanding on the "figured it out on my own".. I'm week 2 into vba so your input on the move function left me clueless on what & where to put the move code. but i trial'd and error'd it until i got it. thats what i meant by on my own.. it was your solution :)

ok i'll try the html formatting but the test emails i've used always come out ugly (lots of formatting garbage). i'll read up.. thx again
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Yep, formatting is an issue. Even MS cannot do that reliably. However, plain text doesn't support what you want.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Can I create a Rule that sends me an email when I get a Task? Using Outlook 2
Diane Poremsky Create a Task from an Email using a Rule Using Outlook 0
Diane Poremsky Create Tasks from Email and move to different Task folders Using Outlook 0
S Create task with email URL instead of attachment Outlook VBA and Custom Forms 4
H Create a Task by Draft-EMail > Task+Reminder not Working Outlook VBA and Custom Forms 1
C Visual Basic auto create task from email including attachments Using Outlook 9
Diane Poremsky Create a Task when a Message is Flagged Using Outlook 0
Diane Poremsky Automatically create a task when sending a message Using Outlook 0
Diane Poremsky Create Task or Appointment and Insert Selected Text Using Outlook 0
M Automatically create event in calendar when task is created Outlook VBA and Custom Forms 1
H Is it possible to create a view that only show the first task in a list? Using Outlook 1
M receive mail when appointment category changes and create task from appointment Outlook VBA and Custom Forms 0
B on flag message event - create task Outlook VBA and Custom Forms 22
S Auto Create new Task upon Current Task completion Outlook VBA and Custom Forms 28
N Macro to create task Using Outlook 1
J OL2010 Create a new task while off line Exchange Server Administration 3
2 Flag for Follow up or create new task Using Outlook 1
S Macro to create a new contact, 2 appointments, and a task Using Outlook 1
J Create new outlook task into task subfolder using vba Using Outlook 6
W How to create a cutsom task field in c#? Using Outlook 1
D create auto number field in task form Outlook VBA and Custom Forms 4
C create a button go to linked account on a task form BCM (Business Contact Manager) 3
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 0
J How to create a drop down user defined field that will appear on an inbox view Outlook VBA and Custom Forms 8
Commodore Any way to create "from-only" account on Outlook 2021? Using Outlook 1
L Capture email addresses and create a comma separated list Outlook VBA and Custom Forms 5
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
NVDon Create new Move To Folder list Outlook VBA and Custom Forms 0
C Create Meeting With Custom Form Outlook VBA and Custom Forms 2
D Create advanced search (email) via VBA with LONG QUERY (>1024 char) Outlook VBA and Custom Forms 2
G Create ordinal numbers for birthday Outlook VBA and Custom Forms 2
O Outlook 365 - How to create / copy a new contact from an existing one? Using Outlook 5
D Create new email from the received Email Body with attachment Outlook VBA and Custom Forms 10
A How to create fixed signatures for aliases that process through GMAIL? Outlook VBA and Custom Forms 0
M How create a Rule to filter sender's email with more that one @ sign Using Outlook 1
B Can I create a local PST file for SPAM on a drive that is usually disconnected? Using Outlook 3
Chiba Create an appointment for all the members Outlook VBA and Custom Forms 1
S Create a clickable custom column field Outlook VBA and Custom Forms 0
O Create a custom contact form - questions before messing things up... Outlook VBA and Custom Forms 4
L automaticaly create a teams meeting with a sync Using Outlook 0
D Can Exchange Admin Center create a pst for users email/contacts/calendar? Exchange Server Administration 0
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
F How to create phone number as links in notes of Contacts Using Outlook 2
Nessa Can't create new appointment Using Outlook 1
A Create date folder and move messages daily Outlook VBA and Custom Forms 1
C Create new Message with shared contacts & BCC'ing recipients Outlook VBA and Custom Forms 0
O Multiple email accounts - hesitate to create a new profile Using Outlook 3
G Can't create Folder Groups in Outlook 2013 Using Outlook 0
N Outlook rules don't create a copy for bcc'ed emails Using Outlook 3
F Delete/create/reset Exchange mailbox on Outlook.com Using Outlook.com accounts in Outlook 3

Similar threads

Top