Differentiate between Task and Task Request in NewInspector event

P

Piyush Gupta

Hi All,

I am handling NewInspector event to show my custom form when user
clicks on "New > Task" or "New > Task Request". But somehow I am
getting same message class (i.e. IPM.Task) for both commands.

Can anyone of you pls. suggest a way to determine that whether
NewInspector request is for "Task" or "Task Request"?

Thanks.
 
S

Sue Mosher [MVP-Outlook]

THe value of the Class property should be different.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
P

Piyush Gupta

THe value of the Class property should be different.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers

Thanks Sue.

That's the problem I am having, No matter if user clicks on "New >
Task" or "New > Task Request", inspector.CurrentItem is of TaskItem
type only. My C# code goes like this:

Outlook.TaskRequestItem taskRequest = inspector.CurrentItem as
Outlook.TaskRequestItem;
Outlook.TaskItem task = inspector.CurrentItem as Outlook.TaskItem;

For new Task and Task Request, taskRequest variable remains null. Is
there any property of TaskItem (other than TeamTask as it is always
false) which can tell me the option selected by user?
 
P

Piyush Gupta

Sue told you. It's Inspector.CurrentItem.Class.

Sorry for the confusion. As I am writing C# code, Class property of
CurrentItem can't be used without casting it to some type and that's
why I am type casting it to TaskItem and TaskItem.Class always returns
IPM.Task. When I type cast it to TaskRequestItem, it returns null.
 
D

Dmitry Streblechenko

Actually MessageClass will be "IPM.Task" and Class will olTask in both
cases.
The only difference will be the ResponseState property: it will be
olTaskSimple (0) for a brand new regular task and olTaskAssign (1) for New |
Task Request.
You can create olTaskAssign out of olTaskSimple by calling TaskItem.Assign.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
P

Piyush Gupta

Actually MessageClass will be "IPM.Task" and Class will olTask in both
cases.
The only difference will be the ResponseState property: it will be
olTaskSimple (0) for a brand new regular task and olTaskAssign (1) for New |
Task Request.
You can create olTaskAssign out of olTaskSimple by calling TaskItem.Assign.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Thanks Dmitry, your suggestion worked and now I am able to
differentiate between Task and Task Request.

Can you pls. suggest way to differentiate between Appointment and
Meeting Request too? Similar to Task problem, I am getting
IPM.Appointment class in both cases.
 
D

Dmitry Streblechenko

Look at the ResponseStatus property.
You can compare objects easily in OutlookSpy - dipaly the item, then hit the
CurrentItem button on the OutlookSpy toolbar and look at the properties.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Piyush Gupta said:
Actually MessageClass will be "IPM.Task" and Class will olTask in both
cases.
The only difference will be the ResponseState property: it will be
olTaskSimple (0) for a brand new regular task and olTaskAssign (1) for
New |
Task Request.
You can create olTaskAssign out of olTaskSimple by calling
TaskItem.Assign.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


On Feb 6, 3:10 pm, "Ken Slovak - [MVP - Outlook]" <[email protected]>
wrote:
Sue told you. It's Inspector.CurrentItem.Class.
Thanks Sue.
That's the problem I am having, No matter if user clicks on "New >
Task" or "New > Task Request", inspector.CurrentItem is of TaskItem
type only. My C# code goes like this:
Outlook.TaskRequestItem taskRequest = inspector.CurrentItem as
Outlook.TaskRequestItem;
Outlook.TaskItem task = inspector.CurrentItem as Outlook.TaskItem;
For new Task and Task Request, taskRequest variable remains null. Is
there any property of TaskItem (other than TeamTask as it is always
false) which can tell me the option selected by user?
Sorry for the confusion. As I am writing C# code, Class property of
CurrentItem can't be used without casting it to some type and that's
why I am type casting it to TaskItem and TaskItem.Class always returns
IPM.Task. When I type cast it to TaskRequestItem, it returns null.

Thanks Dmitry, your suggestion worked and now I am able to
differentiate between Task and Task Request.

Can you pls. suggest way to differentiate between Appointment and
Meeting Request too? Similar to Task problem, I am getting
IPM.Appointment class in both cases.
 
P

Piyush Gupta

Look at the ResponseStatus property.
You can compare objects easily in OutlookSpy - dipaly the item, then hit the
CurrentItem button on the OutlookSpy toolbar and look at the properties.

Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


Actually MessageClass will be "IPM.Task" and Class will olTask in both
cases.
The only difference will be the ResponseState property: it will be
olTaskSimple (0) for a brand new regular task and olTaskAssign (1) for
New |
Task Request.
You can create olTaskAssign out of olTaskSimple by calling
TaskItem.Assign.
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

On Feb 6, 3:10 pm, "Ken Slovak - [MVP - Outlook]" <[email protected]>
wrote:
Sue told you. It's Inspector.CurrentItem.Class.


Thanks Sue.
That's the problem I am having, No matter if user clicks on "New >
Task" or "New > Task Request", inspector.CurrentItem is of TaskItem
type only. My C# code goes like this:
Outlook.TaskRequestItem taskRequest = inspector.CurrentItem as
Outlook.TaskRequestItem;
Outlook.TaskItem task = inspector.CurrentItem as Outlook.TaskItem;
For new Task and Task Request, taskRequest variable remains null. Is
there any property of TaskItem (other than TeamTask as it is always
false) which can tell me the option selected by user?
Sorry for the confusion. As I am writing C# code, Class property of
CurrentItem can't be used without casting it to some type and that's
why I am type casting it to TaskItem and TaskItem.Class always returns
IPM.Task. When I type cast it to TaskRequestItem, it returns null.
Thanks Dmitry, your suggestion worked and now I am able to
differentiate between Task and Task Request.
Can you pls. suggest way to differentiate between Appointment and
Meeting Request too? Similar to Task problem, I am getting
IPM.Appointment class in both cases.

Thanks to everyone. I was able to resolve issue with Response state
property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top