+ Reply to Thread
Results 1 to 3 of 3

Sending Outlook tasks using VBA (almost there, need help)

  1. #1
    Registered User
    Join Date
    04-08-2005
    Posts
    5

    Sending Outlook tasks using VBA (almost there, need help)

    I posted this question previously but didn't get any response. I'm trying to figure out how to send a Task Request via Excel VBA. I was able to get nearly all the way there by following the advice on *****-Clicks.com, although I did discover that you MUST bind the Outlook 10.0 object library FIRST (early binding) using Tools, References in the VBA editor. This seems to be true regardless of whether you include the binding code in your subroutine, it just won't work unless you manually bind it using Tools, References.

    Now I'm nearly all the way there...see the code below. I can create the task request, and it is saved in the task list. Unfortunately the last step, Send, does not work...it attempts to send the request to the task recipient (Mark Walker), but you will get a VBA error asking for at least one name in the To: box. Unfortunately the .To method does not appear to be supported in the object dropdown list (as it is for the email type). The .Recipients method is supported but this does not work, VBA returns an error.

    So all I need is a way to assign a .To recipient for this task request and I'm good to go! I've seen a number of postings on this forum on this topic, so I'm sure many users can benefit from this. Any help would be greatly appreciated, thanks!

    Roy


    Sub TestTask()
    ' Note: You must first manually bind the Outlook 10.0 Object Library by going to
    ' Tool, References in the VBA editor (this is for Outlook 2002). Otherwise the code
    ' below will not work!

    Dim olApp As Object
    Dim olTsk As TaskItem

    Dim Recipient As String
    Recipient = "Mark Walker"

    Set olApp = CreateObject("Outlook.Application")
    Set olTsk = olApp.CreateItem(olTaskItem)

    With olTsk
    .Status = olTaskInProgress
    .Importance = olImportanceHigh
    .DueDate = DateValue("06/26/05")
    .Body = "Test task body"
    .TotalWork = 40
    .ActualWork = 20
    .Assign = "Test Task Mark Walker"
    .Owner = "Mark Walker"
    .Save
    .Send
    End With

    Set olTsk = Nothing
    Set olApp = Nothing

    End Sub

  2. #2
    Registered User
    Join Date
    04-08-2005
    Posts
    5
    Bump...I really need to figure this out today if I can, but I'm not getting any love here...please help if you can, thanks!

  3. #3
    Forum Contributor
    Join Date
    12-11-2004
    MS-Off Ver
    2007
    Posts
    137
    Hello

    in the Excel help there is an exemple

    ( for working in the example , the full name "April LaMonte" must exist in the FolderAdress )
    ...
    Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.CreateItem(olTaskItem)
    myItem.Assign
    myItem.Recipients.Add("April LaMonte")
    myItem.Subject = "Prepare Agenda For Meeting"
    myItem.DueDate = #9/20/97#
    myItem.Send
    ...


    so for you project you may try

    With olTsk
    .Status = olTaskInProgress
    .Importance = olImportanceHigh
    .DueDate = DateValue("06/26/05")
    .Body = "Test task body"
    .TotalWork = 40
    .ActualWork = 20
    .Assign
    .Recipients.Add("Mark Walker") ' the name must exist in the FolderAdress

    .Save
    .Send
    End With



    regards ,
    michel

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1