Attach Sent Item to Task

Posted on 2005-05-02
Last Modified: 2010-04-08
I've got a custom form which sends a message to an addressee and on the Send event automatically creates a task based on the content of the message.  Is it possible to attach the entire sent message to the task at the same time the task is created?

Here's the vbscript I'm using to create the task:

Sub Item_Send()
Set objOutlook = CreateObject("Outlook.application")
Set itmTask = objOutlook.CreateItem(olTaskItem)
With itmTask
.Subject = item.Subject
.Categories = "Contract Request"
.DueDate = NextBusinessDay(now(),7)
.ReminderTime = NextBusinessDay(now(), 5)
.ReminderSet = True
.Body = "Automatically created task based on " & item.Subject & vbCr & vbCr & item.body
End With
Set itmTask = Nothing
Set objOutlook = Nothing
End Sub  
Question by:snipsey
    1 Comment
    LVL 76

    Accepted Solution

    Hi snipsey,

    I've never gotten into creating/modifying Outlook forms so I can't speak directly to whether this is doable from a form or not.  It is doable from Outlook though if you trap the Application_ItemSend event.  In the sample code below I'm allowing a task to be created for every item sent, which of course isn't what you want.  You'd need to put in a test to only catch your modified form being sent.  But this code demonstrates that it is possible, at least at the application level.  

    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        Dim itmTask As Outlook.TaskItem
        Set itmTask = Application.CreateItem(olTaskItem)
        With itmTask
            .Subject = Item.Subject
            .Categories = "Contract Request"
            .DueDate = NextBusinessDay(now(),7)
            .ReminderTime = NextBusinessDay(now(),5)
            .ReminderSet = True
            .Body = "Automatically created task based on " & Item.Subject & vbCr & vbCr & Item.Body
            .Attachments.Add Item
        End With
        Set itmTask = Nothing
    End Sub


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
    Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now