Customize Task view on to-do bar programatically

R

Ryan Taylor

Hello,

I am in the process of creating new Views in Outlook 2007 (C#, VSTO 2008)
and one criteria is to display the Icon property for tasks in both to the
Task Pane, and the To-do Bar.

I am able to programatically create new Views that work perfectly in the
Task Pane, however, I have been unable to figure out how to programmatically
modify the view used in the to-do bar. If any one can point me in the right
direction, I would greatly appreciate it as all I would like to do is add the
Icon property.

Thanks,
Ryan Taylor
 
K

Ken Slovak - [MVP - Outlook]

The To-Do Bar is actually a view of a search folder. The search folder,
To-Do Search, is stored under the Store.RootFolder. You can access it using
this code (assuming you want to get at the To-Do Search folder in the
default Store and "ns" is a NameSpace object:

Outlook.Store defaultStore =
ns.GetDefaultFolder(Outlook.OlDefaultFolder.olFolderInbox).Store;

Outlook.Folder toDo =
defaultStore.GetSpecialFolder(Outlook.OlSpecialFolders.olSpecialFolderAllTasks);

From there you can access the Views collection of the folder and proceed
normally.
 
R

Ryan Taylor

Hi Ken,

Thank you for your quick reply. I tried what you suggested however it
didn't seem to work. I have included the relevant portion of code below, if
you could take a look at it and what I might have missed from your sample, I
would greatly appreciate it.

I am basically just analyzing the current view of the to-do bar and if it
doesn't have the Icon property, trying to add it. I noticed that it WILL add
the icon to the to-list view that you can choose from the task pane, however
it does not seem to add it to the view showing on the to-do bar.


Code
=============
public void somemethod()
{
Folder inboxFolder =
_app.Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox) as Folder;
Folder todoBarFolder =
inboxFolder.Store.GetSpecialFolder(OlSpecialFolders.olSpecialFolderAllTasks)
as Folder;
EnsureIcon(todoBarFolder);
}

private void EnsureIcon(Folder todoBarFolder)
{
TableView view = todoBarFolder.CurrentView as TableView;
bool containsIcon = false;
foreach (object o in view.ViewFields)
{
ViewField field = o as ViewField;
if (field == null)
continue;
if (field.ViewXMLSchemaName.Equals(ICON_NAME,
StringComparison.InvariantCultureIgnoreCase))
{
containsIcon = true;
break;
}
}
if (!containsIcon)
{
view.ViewFields.Insert(ICON_NAME, 1);
view.Save();
}
}
=============

The biggest difference that I see from your code and mine is that I am using
_app.Session, instead of going through the namespace, but I tried both and it
didn't seem to make a difference.

Thanks,
Ryan
 
K

Ken Slovak - [MVP - Outlook]

I guess it all depends on the view itself. I was able to use similar code to
add ReminderTime to the ToDo Bar view, but even though the field is now
there in the view XML and ViewProperties collection it doesn't show up in
the view itself in the UI. The ToDo Bar has some formatting that's on it
that's very hard to change. It has that Arrange By and other things that
prevent some data from showing up.
 
R

Ryan Taylor

Hi Ken,

It sounds like your results were similar to mine. It seems like we just
aren't getting the correct view, it seems like the view the To-do bar is
using ia view from somewhere else even though it has the same name as the
other view. We are able to manually add the icon property by right clicking
on the header (for example: right click on the Arrange by column) and
choosing "Custom...". However, a major peice of this project is showing the
icons for the task, specifically in the to-do bar, so I need to be able to
make sure I can show them without depending on the user to manually go
through the process. Can you think of anything else that we can try?

Thanks again for your help, it is greatly appreciated.

Best Regards,
Ryan Taylor
 
K

Ken Slovak - [MVP - Outlook]

Well, I've had limited success in customizing views of almost any type of
search folder in the past, and the To-Do Bar is just a view into a search
folder. I haven't spent a lot of time on it though, if I have any time
tomorrow I'll play around with it for a while.
 
R

Ryan Taylor

Thanks Ken, it would be really great if you are able to find something.

Thanks,
Ryan
 
R

Ryan Taylor

Hi Ken,

I was wondering if you had any luck with getting other fields (namely the
icon) to show up on the to-do bar programmatically?

Thanks,
Ryan
 
R

Ryan Taylor

Fair enough, thanks for all of the time you spent looking. I wasn't able to
find anything either. Do you know what other otions I have in terms of
finding a solution to this problem?

Thanks,
Ryan
 
K

Ken Slovak - [MVP - Outlook]

None that I know of that will help. Filing a bug with MS or opening a case
with support would likely lead to them telling you it can't be done and may
not be fixed in Outlook 2007 at all.

I'll see if any of my friends have any other ideas.
 
K

Ken Slovak - [MVP - Outlook]

We discussed this privately and I think the reason it's not working is that
the To-Do Bar allows a standard view only and the customization is making
Outlook create a new view behind the scenes. To quote Sue Mosher:

"Outlook does not allow you to
programmatically modify a standard view -- another pain point. If you
try to modify an existing standard view, Outlook clones the settings
and creates a copy that is a user-specific view. My hunch is that the
to-do bar can use only the master view, not the user-specific copy."

Thanks Sue and Diane Poremsky for your help in the discussions.
 
R

Ryan Taylor

Hi Ken,

Thank you for researching this further. I apologize for not responding
sooner, I apparently didn't receive the "new post notification" from the
forum.

It is interesting, through the UI, I can modify that standard view and add
the Icon field to it and it will show up. I do understand what you are
saying, that when making these modifications programmatically, Outlook may
create a copy and actually use the copy, instead of the modified view.

Since I am able to set this manually, is there some macro or something
similar that I can create that will go and physically use the mouse to select
this Icon field?

I know it seems like a small thing, but we customize the icons to indicate
various states so it is really important that the users be able to see it.
Unforunately, I cannot rely on them going and manually adding this field.

Thanks again for all of your help, both you and Sue and Diane,
Ryan
 
K

Ken Slovak - [MVP - Outlook]

No, there's nothing you can do in code. I had also verified this with the PM
who owns the Outlook object model on the Outlook team.
 

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