Creating tasks in Outlook using VB 
Author Message
 Creating tasks in Outlook using VB

Hi,

Can anyone shed some light on how to automatically create tasks in Outlook
for a user?

Right now, I can send an email to a user as a task, yet the user has to
accept or click on the message for the task to be created in their tasks
folder.

I would like the user to run an application which reads emails off the
exchange server for a particular user and create tasks in their tasks folder
automatically.

thanks,
Lonn



Sun, 01 Aug 2004 03:12:35 GMT  
 Creating tasks in Outlook using VB
You'd need to write code using the Outlook object model to read the email messages and create the tasks. Of course, you'd also need permission to write new items to their Tasks folder -- the key method is Application.Namespace.GetSharedDefaultFolder.

--
Sue Mosher, Outlook MVP
   Outlook and Exchange Solutions
   at http://www.slipstick.com

Quote:

> Hi,

> Can anyone shed some light on how to automatically create tasks in Outlook
> for a user?

> Right now, I can send an email to a user as a task, yet the user has to
> accept or click on the message for the task to be created in their tasks
> folder.

> I would like the user to run an application which reads emails off the
> exchange server for a particular user and create tasks in their tasks folder
> automatically.

> thanks,
> Lonn



Sun, 01 Aug 2004 04:07:20 GMT  
 Creating tasks in Outlook using VB
I just wrote a simple app that's doing the same thing
you're doing. The difference is that this is a VB Win32
app and creates a behind the scenes instance of Outlook
and adds Tasks based on some criteria. So in effect what's
happening is that the user is in a sense adding their own
tasks.

Let me know if this helps.

Public Function AddTask(ByVal Subject As String, _
                        ByVal Body As String, _
                        ByVal StartDate As Date, _
                        ByVal DueDate As Date, _
                        ByVal ReminderTime As Date, _
                        ByVal Importance As Integer, _
                        Optional ByVal Contacts As
Outlook.MAPIFolder) As Boolean

Dim onMAPI          As Outlook.NameSpace
Dim otTask          As Outlook.TaskItem
Dim otContact       As Outlook.ContactItem
Dim ofTasks         As Outlook.MAPIFolder

On Error GoTo Er:

    Set onMAPI = GetNamespace("MAPI")
    ' Access the Tasks folder
    Set ofTasks = onMAPI.GetDefaultFolder(olFolderTasks)
    ' Add a New Task Item
    Set otTask = ofTasks.Items.Add(olTaskItem)

    ' Set the properties of the TaskItem
    With otTask
        .Subject = Subject
        .Body = Body
        .StartDate = StartDate
        .DueDate = DueDate
        .Importance = Importance

        ' Set a Reminder for the Task
        .ReminderOverrideDefault = True
        .ReminderSet = True
        .ReminderTime = ReminderTime
        .ReminderPlaySound = True
        .ReminderSoundFile = "reminder.wav"
        ' Save the Task in the Users Tasks
        .Save
    End With

    ' Destroy Objects
    Set onMAPI = Nothing
    Set otTask = Nothing
    Set otContact = Nothing
    Set ofTasks = Nothing

    Exit Function
Er:
    ' Destroy Objects
    Set onMAPI = Nothing
    Set otTask = Nothing
    Set otContact = Nothing
    Set ofTasks = Nothing

    ' Raise Error
    Err.Raise Err.Number, Err.Source, Err.Description
End Function

Quote:
>-----Original Message-----
>You'd need to write code using the Outlook object model

to read the email messages and create the tasks. Of
course, you'd also need permission to write new items to
their Tasks folder -- the key method is
Application.Namespace.GetSharedDefaultFolder.
Quote:

>--
>Sue Mosher, Outlook MVP
>   Outlook and Exchange Solutions
>   at http://www.slipstick.com




Quote:
>> Hi,

>> Can anyone shed some light on how to automatically

create tasks in Outlook
Quote:
>> for a user?

>> Right now, I can send an email to a user as a task, yet
the user has to
>> accept or click on the message for the task to be

created in their tasks
Quote:
>> folder.

>> I would like the user to run an application which reads
emails off the
>> exchange server for a particular user and create tasks

in their tasks folder
Quote:
>> automatically.

>> thanks,
>> Lonn

>.



Sun, 01 Aug 2004 07:02:11 GMT  
 Creating tasks in Outlook using VB
Maybe you can shed some light on this if you managed to
use the code I posted.

Outlook gives you the ability to add Contacts to a Task.
If you do this through the UI, you click the Contacts
button and add them to the task. The Contacts show up
hyperlinked (a Contact form opens if you double click
them) and they are separated by ;'s

Now, I'm trying to do this through code. The object model
is confusing here, because there are two properties of the
TaskItem object, they are Contacts, and ContactNames, and
both are of type String.

If you do something such as TaskItem.Contacts
= "Contact1;Contact2" then they contacts names show up
inte Task Form on the Contacts textbox, but they are not
hyperlinked or recognized as Contact links.

Anyone know how to do this through code ?

Quote:
>-----Original Message-----
>Hi,

>Can anyone shed some light on how to automatically create
tasks in Outlook
>for a user?

>Right now, I can send an email to a user as a task, yet
the user has to
>accept or click on the message for the task to be created
in their tasks
>folder.

>I would like the user to run an application which reads
emails off the
>exchange server for a particular user and create tasks in
their tasks folder
>automatically.

>thanks,
>Lonn

>.



Sun, 01 Aug 2004 07:06:31 GMT  
 Creating tasks in Outlook using VB
What the user sees as Contacts in the UI is actually the Links collection, which points to individual Outlook contact items. It has a Links.Add method that takes a ContactItem as an argument. As you found out, TaskItem.Contacts is a string representation of the names of the items in the Links collection.

--
Sue Mosher, Outlook MVP
   Outlook and Exchange Solutions
   at http://www.slipstick.com

Quote:

> Outlook gives you the ability to add Contacts to a Task.
> If you do this through the UI, you click the Contacts
> button and add them to the task. The Contacts show up
> hyperlinked (a Contact form opens if you double click
> them) and they are separated by ;'s

> Now, I'm trying to do this through code. The object model
> is confusing here, because there are two properties of the
> TaskItem object, they are Contacts, and ContactNames, and
> both are of type String.

> If you do something such as TaskItem.Contacts
> = "Contact1;Contact2" then they contacts names show up
> inte Task Form on the Contacts textbox, but they are not
> hyperlinked or recognized as Contact links.

> Anyone know how to do this through code ?



Sun, 01 Aug 2004 07:22:11 GMT  
 Creating tasks in Outlook using VB

Quote:
> So in effect what's  happening is that the user is in a sense adding their
own
> tasks.

> Let me know if this helps.

Hi George,

Thanks for the code example, it is very similar to what I had written that
creates ones' own tasks.  I was wondering if there was a way to create tasks
for other outlook users programmatically (users on the network of course).

Thanks,
Lonn


Quote:
> I just wrote a simple app that's doing the same thing
> you're doing. The difference is that this is a VB Win32
> app and creates a behind the scenes instance of Outlook
> and adds Tasks based on some criteria. >
> Public Function AddTask(ByVal Subject As String, _
>                         ByVal Body As String, _
>                         ByVal StartDate As Date, _
>                         ByVal DueDate As Date, _
>                         ByVal ReminderTime As Date, _
>                         ByVal Importance As Integer, _
>                         Optional ByVal Contacts As
> Outlook.MAPIFolder) As Boolean

> Dim onMAPI          As Outlook.NameSpace
> Dim otTask          As Outlook.TaskItem
> Dim otContact       As Outlook.ContactItem
> Dim ofTasks         As Outlook.MAPIFolder

> On Error GoTo Er:

>     Set onMAPI = GetNamespace("MAPI")
>     ' Access the Tasks folder
>     Set ofTasks = onMAPI.GetDefaultFolder(olFolderTasks)
>     ' Add a New Task Item
>     Set otTask = ofTasks.Items.Add(olTaskItem)

>     ' Set the properties of the TaskItem
>     With otTask
>         .Subject = Subject
>         .Body = Body
>         .StartDate = StartDate
>         .DueDate = DueDate
>         .Importance = Importance

>         ' Set a Reminder for the Task
>         .ReminderOverrideDefault = True
>         .ReminderSet = True
>         .ReminderTime = ReminderTime
>         .ReminderPlaySound = True
>         .ReminderSoundFile = "reminder.wav"
>         ' Save the Task in the Users Tasks
>         .Save
>     End With

>     ' Destroy Objects
>     Set onMAPI = Nothing
>     Set otTask = Nothing
>     Set otContact = Nothing
>     Set ofTasks = Nothing

>     Exit Function
> Er:
>     ' Destroy Objects
>     Set onMAPI = Nothing
>     Set otTask = Nothing
>     Set otContact = Nothing
>     Set ofTasks = Nothing

>     ' Raise Error
>     Err.Raise Err.Number, Err.Source, Err.Description
> End Function

> >-----Original Message-----
> >You'd need to write code using the Outlook object model
> to read the email messages and create the tasks. Of
> course, you'd also need permission to write new items to
> their Tasks folder -- the key method is
> Application.Namespace.GetSharedDefaultFolder.

> >--
> >Sue Mosher, Outlook MVP
> >   Outlook and Exchange Solutions
> >   at http://www.slipstick.com



> >> Hi,

> >> Can anyone shed some light on how to automatically
> create tasks in Outlook
> >> for a user?

> >> Right now, I can send an email to a user as a task, yet
> the user has to
> >> accept or click on the message for the task to be
> created in their tasks
> >> folder.

> >> I would like the user to run an application which reads
> emails off the
> >> exchange server for a particular user and create tasks
> in their tasks folder
> >> automatically.

> >> thanks,
> >> Lonn

> >.



Sun, 01 Aug 2004 23:05:13 GMT  
 Creating tasks in Outlook using VB
I don't know the answer to that. It seems that when you do
the GetNameSpace("MAPI") call that it's using Outlook in
the context of the currently logged in user... You can
Assign Tasks to other users, but they would appear to be
sent from the user under which your app is running

Quote:
>-----Original Message-----
>> So in effect what's  happening is that the user is in a
sense adding their
>own
>> tasks.

>> Let me know if this helps.

>Hi George,

>Thanks for the code example, it is very similar to what I
had written that
>creates ones' own tasks.  I was wondering if there was a
way to create tasks
>for other outlook users programmatically (users on the
network of course).

>Thanks,
>Lonn



>> I just wrote a simple app that's doing the same thing
>> you're doing. The difference is that this is a VB Win32
>> app and creates a behind the scenes instance of Outlook
>> and adds Tasks based on some criteria. >
>> Public Function AddTask(ByVal Subject As String, _
>>                         ByVal Body As String, _
>>                         ByVal StartDate As Date, _
>>                         ByVal DueDate As Date, _
>>                         ByVal ReminderTime As Date, _
>>                         ByVal Importance As Integer, _
>>                         Optional ByVal Contacts As
>> Outlook.MAPIFolder) As Boolean

>> Dim onMAPI          As Outlook.NameSpace
>> Dim otTask          As Outlook.TaskItem
>> Dim otContact       As Outlook.ContactItem
>> Dim ofTasks         As Outlook.MAPIFolder

>> On Error GoTo Er:

>>     Set onMAPI = GetNamespace("MAPI")
>>     ' Access the Tasks folder
>>     Set ofTasks = onMAPI.GetDefaultFolder(olFolderTasks)
>>     ' Add a New Task Item
>>     Set otTask = ofTasks.Items.Add(olTaskItem)

>>     ' Set the properties of the TaskItem
>>     With otTask
>>         .Subject = Subject
>>         .Body = Body
>>         .StartDate = StartDate
>>         .DueDate = DueDate
>>         .Importance = Importance

>>         ' Set a Reminder for the Task
>>         .ReminderOverrideDefault = True
>>         .ReminderSet = True
>>         .ReminderTime = ReminderTime
>>         .ReminderPlaySound = True
>>         .ReminderSoundFile = "reminder.wav"
>>         ' Save the Task in the Users Tasks
>>         .Save
>>     End With

>>     ' Destroy Objects
>>     Set onMAPI = Nothing
>>     Set otTask = Nothing
>>     Set otContact = Nothing
>>     Set ofTasks = Nothing

>>     Exit Function
>> Er:
>>     ' Destroy Objects
>>     Set onMAPI = Nothing
>>     Set otTask = Nothing
>>     Set otContact = Nothing
>>     Set ofTasks = Nothing

>>     ' Raise Error
>>     Err.Raise Err.Number, Err.Source, Err.Description
>> End Function

>> >-----Original Message-----
>> >You'd need to write code using the Outlook object model
>> to read the email messages and create the tasks. Of
>> course, you'd also need permission to write new items to
>> their Tasks folder -- the key method is
>> Application.Namespace.GetSharedDefaultFolder.

>> >--
>> >Sue Mosher, Outlook MVP
>> >   Outlook and Exchange Solutions
>> >   at http://www.slipstick.com


message

>> >> Hi,

>> >> Can anyone shed some light on how to automatically
>> create tasks in Outlook
>> >> for a user?

>> >> Right now, I can send an email to a user as a task,
yet
>> the user has to
>> >> accept or click on the message for the task to be
>> created in their tasks
>> >> folder.

>> >> I would like the user { w?!?  ?" |Zp5D> ~ to run

an application which reads

- Show quoted text -

Quote:
>> emails off the
>> >> exchange server for a particular user and create
tasks
>> in their tasks folder
>> >> automatically.

>> >> thanks,
>> >> Lonn

>> >.

>.



Mon, 02 Aug 2004 01:20:03 GMT  
 Creating tasks in Outlook using VB
I don't know the answer to that. It seems that when you do
the GetNameSpace("MAPI") call that it's using Outlook in
the context of the currently logged in user... You can
Assign Tasks to other users, but they would appear to be
sent from the user under which your app is running

Quote:
>-----Original Message-----
>> So in effect what's  happening is that the user is in a
sense adding their
>own
>> tasks.

>> Let me know if this helps.

>Hi George,

>Thanks for the code example, it is very similar to what I
had written that
>creates ones' own tasks.  I was wondering if there was a
way to create tasks
>for other outlook users programmatically (users on the
network of course).

>Thanks,
>Lonn



>> I just wrote a simple app that's doing the same thing
>> you're doing. The difference is that this is a VB Win32
>> app and creates a behind the scenes instance of Outlook
>> and adds Tasks based on some criteria. >
>> Public Function AddTask(ByVal Subject As String, _
>>                         ByVal Body As String, _
>>                         ByVal StartDate As Date, _
>>                         ByVal DueDate As Date, _
>>                         ByVal ReminderTime As Date, _
>>                         ByVal Importance As Integer, _
>>                         Optional ByVal Contacts As
>> Outlook.MAPIFolder) As Boolean

>> Dim onMAPI          As Outlook.NameSpace
>> Dim otTask          As Outlook.TaskItem
>> Dim otContact       As Outlook.ContactItem
>> Dim ofTasks         As Outlook.MAPIFolder

>> On Error GoTo Er:

>>     Set onMAPI = GetNamespace("MAPI")
>>     ' Access the Tasks folder
>>     Set ofTasks = onMAPI.GetDefaultFolder(olFolderTasks)
>>     ' Add a New Task Item
>>     Set otTask = ofTasks.Items.Add(olTaskItem)

>>     ' Set the properties of the TaskItem
>>     With otTask
>>         .Subject = Subject
>>         .Body = Body
>>         .StartDate = StartDate
>>         .DueDate = DueDate
>>         .Importance = Importance

>>         ' Set a Reminder for the Task
>>         .ReminderOverrideDefault = True
>>         .ReminderSet = True
>>         .ReminderTime = ReminderTime
>>         .ReminderPlaySound = True
>>         .ReminderSoundFile = "reminder.wav"
>>         ' Save the Task in the Users Tasks
>>         .Save
>>     End With

>>     ' Destroy Objects
>>     Set onMAPI = Nothing
>>     Set otTask = Nothing
>>     Set otContact = Nothing
>>     Set ofTasks = Nothing

>>     Exit Function
>> Er:
>>     ' Destroy Objects
>>     Set onMAPI = Nothing
>>     Set otTask = Nothing
>>     Set otContact = Nothing
>>     Set ofTasks = Nothing

>>     ' Raise Error
>>     Err.Raise Err.Number, Err.Source, Err.Description
>> End Function

>> >-----Original Message-----
>> >You'd need to write code using the Outlook object model
>> to read the email messages and create the tasks. Of
>> course, you'd also need permission to write new items to
>> their Tasks folder -- the key method is
>> Application.Namespace.GetSharedDefaultFolder.

>> >--
>> >Sue Mosher, Outlook MVP
>> >   Outlook and Exchange Solutions
>> >   at http://www.slipstick.com


message

>> >> Hi,

>> >> Can anyone shed some light on how to automatically
>> create tasks in Outlook
>> >> for a user?

>> >> Right now, I can send an email to a user as a task,
yet
>> the user has to
>> >> accept or click on the message for the task to be
>> created in their tasks
>> >> folder.

>> >> I would like the user { w?!?  ?" |Zp5D> ~ to run

an application which reads

- Show quoted text -

Quote:
>> emails off the
>> >> exchange server for a particular user and create
tasks
>> in their tasks folder
>> >> automatically.

>> >> thanks,
>> >> Lonn

>> >.

>.



Mon, 02 Aug 2004 01:20:06 GMT  
 Creating tasks in Outlook using VB
Sue,
Thanks for your help, I simply did this

For Each otContact in Contacts.Items
  Call otTask.Links.Add(otContact)
Next

and the contacts appear linked in the Task

ThankS!

Quote:
>-----Original Message-----
>What the user sees as Contacts in the UI is actually the

Links collection, which points to individual Outlook
contact items. It has a Links.Add method that takes a
ContactItem as an argument. As you found out,
TaskItem.Contacts is a string representation of the names
of the items in the Links collection.
Quote:

>--
>Sue Mosher, Outlook MVP
>   Outlook and Exchange Solutions
>   at http://www.slipstick.com




Quote:

>> Outlook gives you the ability to add Contacts to a
Task.
>> If you do this through the UI, you click the Contacts
>> button and add them to the task. The Contacts show up
>> hyperlinked (a Contact form opens if you double click
>> them) and they are separated by ;'s

>> Now, I'm trying to do this through code. The object
model
>> is confusing here, because there are two properties of
the
>> TaskItem object, they are Contacts, and ContactNames,
and
>> both are of type String.

>> If you do something such as TaskItem.Contacts
>> = "Contact1;Contact2" then they contacts names show up
>> inte Task Form on the Contacts textbox, but they are
not
>> hyperlinked or recognized as Contact links.

>> Anyone know how to do this through code ?

>.



Mon, 02 Aug 2004 01:32:53 GMT  
 Creating tasks in Outlook using VB
Instead of Namespace.GetDefaultFolder, you'd use Namespace.GetSharedDefaultFolder.

--
Sue Mosher, Outlook MVP
   Outlook and Exchange Solutions
   at http://www.slipstick.com

Quote:
>-----Original Message-----
>Thanks for the code example, it is very similar to what I
had written that
>creates ones' own tasks.  I was wondering if there was a
way to create tasks
>for other outlook users programmatically (users on the

network of course).


Mon, 02 Aug 2004 02:55:23 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Creating mail accounts for Outlook/Outlook Express using VB

2. Find Tasks created from MS Project 2000 in Outlook 2000

3. Final answer: Creating an Outlook Task from MS Word 2000

4. Repost: Creating an Outlook Task from MS Word 2000

5. Creating an Outlook Task from MS Word 2000

6. Create task's in MS Outlook from VB4.0 application

7. Create task's in MS Outlook from VB4.0 application

8. Outlook & Re-Occuring tasks using VBE

9. How to: Programmatically assign outlook tasks using eVB

10. Using Visual Basic to create and send email using Outlook

11. How to create a new task using VBA?

12. How do you create a task using VBA???

 

 
Powered by phpBB® Forum Software