Adding tasks to a named task list 
Author Message
 Adding tasks to a named task list

I can add a task to the logged in users task list easily enough. I can't
seem to figure out how I add a task to a specific task list in a specific
folder though.

Essentialy I have a mailbox called "Customer Callback" containing a tasl
list called "Customer Callbacks". I can get an object reference to it using
:

oOutlook = createobject("Outlook.Application")
oMapi = oOutlook.GetNameSpace("MAPI")
oTaskList = oMapi.folders["Mailbox - Customer Callback"].folders["Customer
Callbacks"]

But I just can't figure out how to add my task to it. Any tips would be very
welcome.

TIA
Nigel



Sun, 13 Feb 2005 17:28:18 GMT  
 Adding tasks to a named task list
You need to resolve the mailbox first along the lines of:-

Set oMailBoxOBJ = oMapi.CreateRecipient("Customer
Callback")

oMailBoxOBJ.Resolve
If oMailBoxOBJ.Resolved Then

  ' next you need to get the folder you want to work with
  ' then add the items using the Items Add Method
  With oFolder.Items.Add("MessageClass")
    .Status = 0 ' Not Started
    .Unread = True
    .Save
  End With

End If

Quote:
>-----Original Message-----
>I can add a task to the logged in users task list easily
enough. I can't
>seem to figure out how I add a task to a specific task
list in a specific
>folder though.

>Essentialy I have a mailbox called "Customer Callback"
containing a tasl
>list called "Customer Callbacks". I can get an object

reference to it using
Quote:
>:

>oOutlook = createobject("Outlook.Application")
>oMapi = oOutlook.GetNameSpace("MAPI")
>oTaskList = oMapi.folders["Mailbox - Customer

Callback"].folders["Customer
Quote:
>Callbacks"]

>But I just can't figure out how to add my task to it. Any
tips would be very
>welcome.

>TIA
>Nigel

>.



Sun, 13 Feb 2005 18:32:56 GMT  
 Adding tasks to a named task list
That,s great Dave, I can resolve it fine now, but where did your oFolder
object come from?

Nigel


Quote:
> You need to resolve the mailbox first along the lines of:-

> Set oMailBoxOBJ = oMapi.CreateRecipient("Customer
> Callback")

> oMailBoxOBJ.Resolve
> If oMailBoxOBJ.Resolved Then

>   ' next you need to get the folder you want to work with
>   ' then add the items using the Items Add Method
>   With oFolder.Items.Add("MessageClass")
>     .Status = 0 ' Not Started
>     .Unread = True
>     .Save
>   End With

> End If

> >-----Original Message-----
> >I can add a task to the logged in users task list easily
> enough. I can't
> >seem to figure out how I add a task to a specific task
> list in a specific
> >folder though.

> >Essentialy I have a mailbox called "Customer Callback"
> containing a tasl
> >list called "Customer Callbacks". I can get an object
> reference to it using
> >:

> >oOutlook = createobject("Outlook.Application")
> >oMapi = oOutlook.GetNameSpace("MAPI")
> >oTaskList = oMapi.folders["Mailbox - Customer
> Callback"].folders["Customer
> >Callbacks"]

> >But I just can't figure out how to add my task to it. Any
> tips would be very
> >welcome.

> >TIA
> >Nigel

> >.



Sun, 13 Feb 2005 19:36:13 GMT  
 Adding tasks to a named task list
This bit is a little more complex, I use the
GetSharedDefaultFolder method to retrieve the mailbox's
default task folder.

Set oFolder = oMapi.GetSharedDefaultFolder    
(oMailBoxObj, olFolderTasks)

Where oMailBoxObj is the resolved user mail store and
oFolderTasks is the inbuilt CONSTant for the folder type.

However I think you'll have to enumerate the folders
within the TaskList folder to find the one you're looking
for.  

ie:

dim myFolder As Object
Set oFolder = oMapi.GetSharedDefaultFolder _
(oMailBoxObj,olFolderTasks)
for each myFolder in oFolder

  If myFolder.Name = "Match name Here" Then

    ' Do Add Routine
    with myFolder
    end with

  End If

Next myFolder

I think there may be another way via the
GetFolderFromID method in that your first posted example
can retrieve the folder directly:

Set myolapp = CreateObject("Outlook.Application")
Set myNameSpace = myolapp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderTasks)
myEntryID = myFolder.EntryID
myStoreID = myFolder.StoreID
Set myFolder = myNameSpace.GetFolderFromID(myEntryID,
myStoreID)

Quote:
>-----Original Message-----
>That,s great Dave, I can resolve it fine now, but where
did your oFolder
>object come from?

>Nigel



>> You need to resolve the mailbox first along the lines
of:-

>> Set oMailBoxOBJ = oMapi.CreateRecipient("Customer
>> Callback")

>> oMailBoxOBJ.Resolve
>> If oMailBoxOBJ.Resolved Then

>>   ' next you need to get the folder you want to work
with
>>   ' then add the items using the Items Add Method
>>   With oFolder.Items.Add("MessageClass")
>>     .Status = 0 ' Not Started
>>     .Unread = True
>>     .Save
>>   End With

>> End If

>> >-----Original Message-----
>> >I can add a task to the logged in users task list
easily
>> enough. I can't
>> >seem to figure out how I add a task to a specific task
>> list in a specific
>> >folder though.

>> >Essentialy I have a mailbox called "Customer Callback"
>> containing a tasl
>> >list called "Customer Callbacks". I can get an object
>> reference to it using
>> >:

>> >oOutlook = createobject("Outlook.Application")
>> >oMapi = oOutlook.GetNameSpace("MAPI")
>> >oTaskList = oMapi.folders["Mailbox - Customer
>> Callback"].folders["Customer
>> >Callbacks"]

>> >But I just can't figure out how to add my task to it.
Any
>> tips would be very
>> >welcome.

>> >TIA
>> >Nigel

>> >.

>.



Sun, 13 Feb 2005 21:51:37 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Keep updated copy of this task on my task list

2. VBA task insert into an existing task list?

3. Hiding Task ID in Task List

4. need help on ending a task in windows task list

5. Program ID does not appear in Task Bar and Task List

6. Removing a task from the WinNT task list...

7. Add a task to task scheduler

8. How to add a task into Windows Task Scheduler from VB

9. Adding tasks to WIN95/98 Task Scheduler

10. Adding tasks to WIN95/98 Task Scheduler

11. List Field Names in Task Table

12. Change Task List Name

 

 
Powered by phpBB® Forum Software