How do I add an outlook task
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?
Re: How do I add an outlook task
Yes, but from within Outlooks VBA or from VB6?
Moved from Classic VB. :)
Re: How do I add an outlook task
Re: How do I add an outlook task
I whipped this up real fast so it may have an error but its the logic and mechanics that are important.
VB Code:
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
Re: How do I add an outlook task
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?
Re: How do I add an outlook task
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?
Re: How do I add an outlook task
Oh ok
Outlook 2003 (11.5608.5606)
Re: How do I add an outlook task
Ok, then everythng should be supported in your version. I am running Office SP2 though but shouldnt make a difference here.
Re: How do I add an outlook task
Yep added no problem
Thanks
Re: How do I add an outlook task
Your Welcome :)
Ps, dont forget to 'Resolve' your thread now that its solved. ;)