how to automate outlook 2003

  • Thread starter Thread starter TM
  • Start date Start date
T

TM

I would like to write a little app in Visual Basic .net as an add-in to
Outlook 2003 so that I can quickly get a list of contact names and email
addresses, then when I click on a name or email address, I want to open a
new mail message to that person.

I don't want to send the message, just open a new blank email so that I can
make it easier to send messages.

Any idea how I could find out more about how to do this ?

Thanks
 
Ok, most of the addin information is way over my head. I was able to find
the code to list the name and email from the contacts collection, but the
sort property is not working and I am getting a security warning when I try
and run the program saying that a program is trying to access email
addresses I have in outlook and do I want to allow this.

First, how can I bypass that warning in Outlook 2003 ?

Here is my sample code. FOr now I am just adding an item to a listbox with
the fileas name and email address so I can see what is going on. I would
like to add these seperately to a datagrid so it looks nicer. Not sure how
to do that but any help is appreciated.

Any idea why the sort is nor working to sort the contacts by FileAs name ?


Dim OutlookApp As New Outlook.Application

Dim OLNameSpace As Outlook.NameSpace

OLNameSpace = OutlookApp.GetNamespace("MAPI")

Dim allContacts As Outlook.MAPIFolder =
OLNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

allContacts.Items.Sort("FileAs")

Dim contact As Outlook.ContactItem

Dim cnt As Integer

lblNumberContacts.Text = "Total Contacts: " & allContacts.Items.Count

lstContacts.Items.Clear()

For cnt = 1 To allContacts.Items.Count

contact = allContacts.Items.Item(cnt)

lstContacts.Items.Add(contact.FileAs & " " & contact.Email1Address)

Next

'cleanup

OutlookApp = Nothing

OLNameSpace = Nothing

Thanks all
 
TM,
First, how can I bypass that warning in Outlook 2003 ?
The warning is there to prevent users from writing viruses, luckily for
Outlook 2003, properly constructed COM-Addins will avoid the warning.

See:
http://msdn.microsoft.com/library/d...dc_ol2003_ta/html/odc_olsecnotescomaddins.asp

Further info can be found at:
http://www.slipstick.com/dev/ol2003problems.htm

The links I gave have samples of creating add-ins.

Both of these are good articles to start with:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnout2k2/html/odc_oladdinvbnet.asp

http://support.microsoft.com/?kbid=302896

Also, be certain you have explicitly installed the Outlook PIAs!

Hope this helps
Jay
 
That is very interesting although it does not explain why the sort property
of the contacts folder is not working
 
Back
Top