Creating forms via Add-Ins

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Outlook 2002 and above.

I am writing my first Add-In for Outlook.
Using VS 2005 and the Extensibility project.
I am not using VSTO.
I am using C# not VB.

I have been googling around, but as soon as I mention I want to create a
"form", all the suggestions indicate I should create the form inside the
Outlook UI.

I need to write an Add-In that will:
1. Open an object (mail, cal, task, contact)
2. Display a button to assign it to an account
3. Display a list of accounts and allow the user to choose which one
4. Save the account number in a user defined field of the object.

So far:
1&2. This was easy enough, found lots of examples that allowed me to create
the button and perform an action.

3. I will be getting the list of accounts from an external source (a
database actually). I guess I could create a folder and add items into this
folder (not sure how to make the items in the folder read-only).
So how do I create a form via the AddIn on the fly to allow the user to
choose from a list of accounts?
I am looking for a link to some sample that does something similar, I am
guessing there is something out there that I can't find that will get me
there most of the way.

4. That should be as simple as:
Item.Userproperties.Add("MyField", 1) (but in C#).

Any pointers or articles to get me on my way will be greatly appreciated.

Thanks,
Dave
 
You don't really want to create a form as I understand it, you want to
create Outlook items. That's something different.

You can use Application.CreateItem to create whatever type items they are
and populate the fields of the item with the information from your database
tables.

The only thing to be aware of is that items will be created in the default
folder for that type of item (even in some cases if you got the folder you
wanted the item in and used the folder.Items.Add() method.

If that happens just save the item and then move it where you want it.
 
Thanks for the response.

That is part of my problem, I am lacking the Outlook terminology.

Let me describe what I plan to do, and then maybe you can equate it to how I
would do it.

When Outlook starts and loads my Add-In I will be connecting to a database.
The database has a list of accounts in a table.

When I open an object (email or contact) when I push a button I want to
display (a form?) the list of accounts and allow the user to choose which
account to "assign" this item to.

Once chosen, I will update the database with the Outlook GUID.

When I reopen the item and press the button again to redisplay the list of
accounts I want to check the one chosen. In this case, it could easily be a
combo box or something similar.

Is that better?

Dave
 
In that case just use a Windows.Form object instead of worrying about
Outlook custom forms. When the button on the Inspector (open item window) is
clicked you open the form and display a listbox or whatever on the form with
other controls as appropriate. That's all you need to do.
 
Back
Top