Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Outlook Tasks (VB6)

    With the following code:

    <pre> Dim objTask
    Set objTask = Application.CreateItem(olTaskItem)
    objTask.Subject = "This is a task test"
    objTask.DueDate = Date
    objTask.ContactNames.Show
    objTask.Save</pre>


    I can set myself a task via a simple command button.
    I think I can use the .ContactNames property so I can set the task to another person.
    My code bombs out after I am prompted by Outlook to allow access to the contact names tabl.
    I've looked in Microsofts msdn etc and can't really find any information on this.
    Has anyone used this before and shed some light on the problem ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook Tasks (VB6)

    ContactNames is a string, not an object, so it doesn't have a Show method.
    The ContactNames property stores the names of contacts associated with the task. If you want to assign a task to someone else, you probably want to set its Recipients, e.g.

    objTask.Recipients.Add "you@company.co.uk"

    If you want to send the task, use

    objTask.Send

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Tasks (VB6)

    Thanks Hans

    I was hoping I could access the Outlook address book and select a recipient from there.
    Maybe I'll have to create a list box with there names in.

    Can a list be populated with the address book ?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook Tasks (VB6)

    If you include the line

    objTask.Display

    the task will be displayed on screen, and the user can click Assign Task and select a recipient.

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Tasks (VB6)

    Hans

    I managed to source the address list as follows:

    <pre>Dim msoAddList As Outlook.AddressList
    Dim msoAddEntry As Outlook.AddressEntry

    ' Change 'Contacts' if required:
    Set msoAddList = Application.Session.AddressLists("Global Address List")

    For Each msoAddEntry In msoAddList.AddressEntries
    List2.AddItem msoAddEntry.Name
    Next
    Set msoAddList = Nothing
    Set msoAddEntry = Nothing</pre>

    ]

    But the task doesn't show on the recipient machine when sent, although nothing hic-ups ???

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook Tasks (VB6)

    Insert the line

    objTask.Assign

    before adding a recipient (you do add the selected recipient(s) from the list box, I hope)

  7. #7
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Tasks (VB6)

    Hans

    I found a different code snippet:

    http://msdn.microsoft.com/library/default...._HV05247490.asp

    <pre>Sub AssignTask()
    Dim myOlApp As New Outlook.Application
    Dim myItem As Outlook.TaskItem
    Dim myDelegate As Outlook.Recipient
    Set myItem = myOlApp.CreateItem(olTaskItem)
    myItem.Assign
    Set myDelegate = myItem.Recipients.Add(List2)
    myDelegate.Resolve
    If myDelegate.Resolved Then
    myItem.Subject = "This is a test"
    myItem.DueDate = Date
    myItem.Display
    myItem.Send
    End If
    End Sub</pre>


    From a Microsoft site, whichever way I do this, I get an error highlliting the "myitem.assign"

  8. #8
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Tasks (VB6)

    Thats very interesting ?
    I'll do a re-boot and see what happens, perhaps I need to close the application (Set myItem = Nothing) in case somethings still present in memory.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook Tasks (VB6)

    Sorry, I can't explain that. Your code runs without errors for me. What happens if you save the task item before trying Assign?

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Outlook Tasks (VB6)

    Might be useful to advise which version of Outlook you are instancing. The Object model is somewhat less exposed, and fewer Properties are writeable, in Outlook 2000. But the differences between XP and 2003 in VBA Objects and Properties are slight.
    -John ... I float in liquid gardens
    UTC -7ąDS

  11. #11
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Tasks (VB6)

    John, I'm using 2003 SP2 if it makes a difference.

    BTW
    I'm still having problems with it.
    On one PC I can send a task without a glitch, on others I get random errors as the post above.
    Maybe it's a share/permission thing !

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook Tasks (VB6)

    Can you detect any relevant difference between the PCs where it works and those where it doesn't? For example:
    - Different Windows version
    - Different Office version
    - Stand-alone or network

  13. #13
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Tasks (VB6)

    Hans

    All specs are the same, Office versions are all the same .

    It seems the tasks are getting through, and I am recieving responses when they have been accepted also.

    I don't know, Maybe I should just skip the errors and see how it goes !!

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Outlook Tasks (VB6)

    Did you get around to trying out my suggestion from <post:=580,364>post 580,364</post:>? I.e. save the item before assigning it:

    ...
    myItem.Save
    myItem.Assign
    ...

  15. #15
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Outlook Tasks (VB6)

    Strange !!

    I could have sworn I did, alls ok now !!

    <pre>Private Sub Command1_Click()
    Dim myOlApp As New Outlook.Application
    Dim myItem As Outlook.TaskItem
    Dim myDelegate As Outlook.Recipient

    Set myItem = myOlApp.CreateItem(olTaskItem)
    myItem.Assign
    Set myDelegate = myItem.Recipients.Add(List2)
    myDelegate.Resolve
    If myDelegate.Resolved Then
    myItem.Subject = "This is a test"
    myItem.DueDate = Date
    myItem.Display
    myItem.Save
    myItem.Send
    End If
    Set myItem = Nothing
    Set myOlApp = Nothing
    End Sub</pre>


Page 1 of 2 12 LastLast

Posting Permissions

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