Click to See Complete Forum and Search --> : How do I add an outlook task
Colex
Feb 23rd, 2006, 01:28 PM
I want to create an outlook task based on a userform textbox entry (e.g. AA001 AA002 etc).
I would like to create the task so that the start date and due date are 20 working days in the future and creation is triggered when an email is sent.
Can anybody help please?
RobDog888
Feb 23rd, 2006, 02:12 PM
Yes, but from within Outlooks VBA or from VB6?
Moved from Classic VB. :)
Colex
Feb 23rd, 2006, 02:15 PM
Sorry - from VB6
RobDog888
Feb 23rd, 2006, 02:21 PM
I whipped this up real fast so it may have an error but its the logic and mechanics that are important.
Option Explicit
'Add a reference to MS Outlook xx.0 Object Library
'Outlook 2003 used for the ex.
Public WithEvents oApp As Outlook.Application
Private oApp As Outlook.Application
Private Sub Form_Load()
Set oApp = New Outlook.Application
End Sub
Private Sub oApp_NewMailEx(ByVal EntryIDCollection As String)
Dim oTask As Outlook.TaskItem
Dim oEmail As Object
Set oEmail = EntryIDCollection
Set oTask = oApp.CreateItem(olTaskItem)
With oTask
.StartDate = DateAdd("d", 20, Date)
.DueDate = DateAdd("d", 20, Date)
.Subject = oEmail.Subject & " - I dont know"
.ReminderSet = False
.Body = "Dont forget."
.Save
End With
Set oEmail = Nothing
Set oTask = Nothing
End Sub
Colex
Feb 23rd, 2006, 02:38 PM
Thanks
Being new to this though I'm stuck when I get the following error
Compile Error
User-defined tyoe not defined
for the Dim oTask As Outlook.TaskItem line
Have I missed something?
RobDog888
Feb 23rd, 2006, 02:42 PM
Yes, you need to 'Add a reference to MS Outlook xx.0 Object Library
by going into your Project menu and clicking References.... Then select Outlook and click OK. :)
What version of Outlook are you running?
Colex
Feb 23rd, 2006, 02:49 PM
Oh ok
Outlook 2003 (11.5608.5606)
RobDog888
Feb 23rd, 2006, 02:51 PM
Ok, then everythng should be supported in your version. I am running Office SP2 though but shouldnt make a difference here.
Colex
Feb 23rd, 2006, 02:57 PM
Yep added no problem
Thanks
RobDog888
Feb 23rd, 2006, 03:01 PM
Your Welcome :)
Ps, dont forget to 'Resolve' your thread now that its solved. ;)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.