w00t! .NET and COM Interop ***UPDATE: I populated a listbox!***

joohang

Lifer
Oct 22, 2000
12,340
1
0
I got bored today so I opened up Visual Studio .NET and began to code away a small app called "StickyTask".

The idea is to list my Outlook tasks as a sticky on my desktop with the 3 fields I actually use. What I often found annoying about Outlook Tasks is that it's always hidden away from me. I want an app that interacts with my Outlook folders and have a sticky on one of my secondary monitor for easy access and actually remind me that I have tasks to do.

I added a reference to the Microsoft Outlook COM object in Visual Studio and now I have full access to the Outlook COM library in a C# application. :D

If I get this thing to work, I'll post it up here, including the source code perhaps. :)

Edit: See code below.

Now I'll play around with the UI, make things pretty, and add some add/edit/update/delete/filter functions to it.
 

StageLeft

No Lifer
Sep 29, 2000
70,150
5
0
You should I'd like to do some basic buggaring around with outlook as well.

What I really want is to play around with MSN messenger as well but I haven't gotten around to it yet...
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
Grrr.. it's confusing to follow the documentation because it assumes that I am doing this in VBA.

I need to find out the right constant for the Tasks folder. The documentation only tells me the ones for mail boxes and calendar. :confused:
 

joohang

Lifer
Oct 22, 2000
12,340
1
0


<< have you tried connection net to a sql server. man is it ever fast. tons faster then EM ever was. >>


Yup. I played around quite a bit with ADO.NET. It has nice data caching mechanism too.

And since DataSet is so powerful, it allows me to extract the necessary data including its data relations and do all the manipulation with the in-memory data store. I don't have to make unnecessary trips to the data server. :D
 

joohang

Lifer
Oct 22, 2000
12,340
1
0


<< man i wish i had more free time, i'd be doing about the same thing :) >>


LOL.

Would you trade your neffing time for it? ;)
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
Took me forever to find the friggin' constant for olFolderTask.
rolleye.gif


God bless Google and Deja.

The magic number was 13.
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
OK. Now I feel REALLY dumb.

I could access this through IntelliSense. Damn..

<-- talking to himself
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0


<< Took me forever to find the friggin' constant for olFolderTask >>



Object browser is your friend :D
 

joohang

Lifer
Oct 22, 2000
12,340
1
0


<<

<< Took me forever to find the friggin' constant for olFolderTask >>



Object browser is your friend :D
>>


Looks like I found a new friend! :)

It was really dumb, though. Visual Studio even told me with a tooltip exactly what I should punch in. And I totally missed it. LOL. :)
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
So here's the code. I didn't copy and paste the whole thing for simplicity. Feel free to criticize my code if it sucks. :)

using Microsoft.Office.Core;

private void PopulateTasks()
{
Outlook.Application outlook = new Outlook.ApplicationClass();
Outlook.NameSpace mapiNamespace = outlook.GetNamespace("MAPI");
Outlook.MAPIFolder mapiFolder = mapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);

Outlook.Items taskItems = mapiFolder.Items;
taskItems.GetFirst();

Outlook.TaskItem taskItem;

for (int i = 1; i <= mapiFolder.Items.Count; i++)
{
taskItem = (Outlook.TaskItem) taskItems.Item(i);
listBox1.Items.Add(taskItem.Subject);
}

taskCountLabel.Text = mapiFolder.Items.Count.ToString();
}

It didn't let me do a foreach with the TaskItems. Bummer.
 

joohang

Lifer
Oct 22, 2000
12,340
1
0


<< C# yuck! :eek: >>


OK. You must be drunk if you can't read that. :p ;)

It doesn't look any much different in VB. :)