I’ve created a couple of custom VBA functions for Outlook 2007 from some snippets at www.outlookcode.com and thought that someone else may find them useful. The first allows you to create a task from an email and modify the Update List recipients (something that you cannot do manually). This also works in Outlook 2003. The second is a timestamp that allows you to inject a timestamp into a task body without modifying the format of the body (using the Word object library).
Create a Task from an Email with the Ability to add Update List Recipients
Instructions: Copy the code below and paste it into the VBA editor in Outlook (access the editor by pressing ALT+F11 in Outlook). Then create a button on the Quick Access Toolbar for mail messages that accesses the MakeTaskFromEmail() function.
Sub MakeTaskFromEmail()
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim objTask As Outlook.TaskItem
Set objMail = Outlook.Application.ActiveInspector.CurrentItem
strID = objMail.EntryID
Set olNS = Application.GetNamespace(”MAPI”)
Set olMail = olNS.GetItemFromID(strID)
Set objFolder = olNS.PickFolder
Set objTask = objFolder.Items.Add(olTaskItem)
objRecipients = InputBox(”Please enter any additional users to Update separated by semicolons:”, “Update List Users”)
With objTask
.Subject = olMail.Subject
.Body = olMail.Body
.StatusUpdateRecipients = olMail.SenderEmailAddress & “; ” & objRecipients
.StatusOnCompletionRecipients = olMail.SenderEmailAddress & “; ” & objRecipients
End With
Call TaskAttachments(olMail, objTask)
objTask.Display
Set objTask = Nothing
Set olMail = Nothing
Set olNS = Nothing
End Sub
Sub TaskAttachments(objSourceItem, objTargetItem)
Set fso = CreateObject(”Scripting.FileSystemObject”)
Set fldTemp = fso.GetSpecialFolder(2)
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
Next
Set fldTemp = Nothing
Set fso = Nothing
End Sub
TimeStamp Using WordEditor in Outlook 2007
Instructions: Copy the code below and paste it into the VBA editor in Outlook (access the editor by pressing ALT+F11 in Outlook). Then create a button on the Quick Access Toolbar for tasks that accesses the TimeStamp() function. You will also have to enable the Word object library in Tools -> References in the VBA editor.
Sub TimeStamp()
Dim strText As String
Dim objItem As Object
Dim objExpl As Outlook.Explorer
Dim objInsp As Outlook.Inspector
Dim objDoc As Word.Document
On Error Resume Next
Set objNameSpace = Application.GetNamespace(”MAPI”)
MyName = objNameSpace.CurrentUser.Name
strText = “>> ” & Date & ” ” & Time & ” ” & MyName & “:” & vbCrLf & vbCrLf & vbCrLf
Set objExpl = Application.ActiveExplorer
Set objItem = objExpl.Selection(1)
If Not objItem Is Nothing Then
Set objInsp = objItem.GetInspector
If objInsp.EditorType = olEditorWord Then
Set objDoc = objInsp.WordEditor
objDoc.Characters(1).InsertBefore strText
Else
MsgBox “Cannot insert text in a formatted message unless Word is the editor”
End If
End If
Set objInsp = Nothing
Set objDoc = Nothing
Set objExpl = Nothing
Set objItem = Nothing
Set objMsg = Nothing
End Sub


I'm pretty technical, and got into the editor pasted the code, but from that point on the instruction is not "complete" ie. not sure how to get that command into the quick access toolbar. I can bring up the toolbar options, but don't know where to see the new command.
I use the "Gettings Things Done" add-on which takes care of creating a task from an email and more, but I would love to be able to mod the update list.
Anton, it's a Macro. When customizing the toolbar, the MakeTaskFromEmail() function should be listed in the "Macros" category.
Andy
Thanks for posting this. You can make the MakeTaskFromEmail macro a bit more efficient by declaring objFolder as a MAPIFolder, and by using it to set an object reference to the default Tasks folder, which is where everyone usually keeps their tasks:
Set objFolder = olNS.GetDefaultFolder(olFolderTasks)
HTH,
JP
Jimmy, originally that's how I had it set up. However, that wouldn't allow a user to specify a task folder in a different mailbox. The users I developed this for use multiple mailboxes, so I setup the folder selection for them.
Andy