|
-
May 16th, 2006, 08:34 AM
#1
Thread Starter
New Member
Outlook task event
I am using outlook 2003 you can assign a task and send it to another person and it stays in the other person email until he accepts it, i want to automatically accept the task for the user, i can't find an event which gets triggered
can anyone there help me please
thanks heaps
-
May 16th, 2006, 09:07 AM
#2
Thread Starter
New Member
Re: Outlook task event
Hi, i found this
This Microsoft Visual Basic/Visual Basic for Applications (VBA) example accepts a TaskRequestItem, sending the response without displaying the inspector.
Sub AcceptTask()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myTasks As Outlook.MAPIFolder
Dim myNewTaskItem As Outlook.TaskItem
Dim mytaskreqItem As Outlook.TaskRequestItem
Dim myItem As Outlook.TaskItem
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myTasks = myNameSpace.GetDefaultFolder(olFolderInbox)
Set mytaskreqItem = myTasks.Items.Find("[Subject] = ""Meeting w/ Nate Sun""")
If Not TypeName(mytaskreqItem) = "Nothing" Then
Set myNewTaskItem = mytaskreqItem.GetAssociatedTask(True)
Set myItem = myNewTaskItem.Respond(olTaskAccept, True, True)
myItem.Send
End If
End Sub
however i think this one assumes that we know the subject name of the email that has the taskrequestitem is there's a way to go around that?
or even another totally different way @@?
-
May 16th, 2006, 09:35 AM
#3
Re: Outlook task event
Can't you just catch them in the inbox when new mail arrives? Here's a bit of sample code, you'll have to add something to screen the ones that you want to autorespond to, but this should give you a start. Drop this "ThisOutlookSession".
VB Code:
Private Sub Application_NewMail()
Dim oInBox As MAPIFolder, oItem As Object, oResponse As TaskItem
Set oInBox = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
For Each oItem In oInBox.Items
If TypeName(oItem) = "TaskItem" Then
Set oResponse = oItem.Respond(olTaskAccept, True, False)
oResponse.Send
End If
Next oItem
Set oResponse = Nothing
Set oInBox = Nothing
End Sub
-
May 17th, 2006, 10:33 PM
#4
Re: Outlook task event
Since your using Outlook 2003 you can use the Application_NewMailEx event as it passes in a parameter of the newmailitem. Then instead of looping through the items you can just use the referenced Item and test for its type and/or its subject like you were doing.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|