Outlook Programming

B

Brian P. Hammer

All - I am having an issue when programming a VB.net app and getting data
from the Outlook address book. I have a button on my form that allows a
user to select a contact from the Outlook address book. I have no problem
displaying it and getting values from the address book, but the values are
not what I expect. I get a seesion to Outlook, logon, and then display the
address book with oSession.AddressBook(Title:="Asset Advisory",
RecipLists:=1) The address book displays fine and I can add a name from any
of the address lists.

When I click the "to" the name properly shows up and then clicking OK closes
the form and I set a couple properties for strUser = CStr(orecip(1).Name) &
strEmail = CStr(orecip(1).Address).

orecip.address properly shows the email address but orecip.Name does not.
It always shows the "Display As" for the email address and not the Full Name
or File As for the contact record.

What is the best way to show an address list and then be able to get to the
underlying data such as the name, email address, business address and all
the other stuff?

I have tried this using CDO and Outlook Objecgt Model with no luck.

Thanks,
Brian





Dim om As New Outlook.SecurityManager
Dim oSession As MAPI.Session = Nothing
Dim orecip As Object = Nothing
Dim strProfileInfo As String = appProperties.Properties.ExchangeServer &
vbLf & appProperties.Properties.UserName
Dim blnIsOpen As Boolean
Err.Clear()
om.DisableCDOWarnings = True
oSession = CreateObject("MAPI.Session")
Try
oSession.Logon(ProfileName:=appProperties.Properties.EmailProfileName,
NewSession:=False, ShowDialog:=False)
blnIsOpen = True
Catch
Try
oSession.Logon(ProfileName:=appProperties.Properties.EmailProfileName,
NewSession:=True, NoMail:=True) ', ShowDialog:=False,
ProfileInfo:=strProfileInfo)
Catch ex As Exception
MessageBox.Show("Could not establish a connection to Outlook. Try opening
Outlook and then trying again.", appConstants.Contstants.gstrcAppTitle,
MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Function
End Try
blnIsOpen = False
End Try
Try
orecip = oSession.AddressBook(Title:="Asset Advisory", RecipLists:=1)
strUser = CStr(orecip(1).Name)
strEmail = CStr(orecip(1).Address)
Catch ex As System.Runtime.InteropServices.COMException
strUser = String.Empty
strEmail = String.Empty
Return False
Finally
If Not (oSession Is Nothing) Then
oSession.Logoff()
oSession = Nothing
End If
om.DisableCDOWarnings = False
End Try
 
J

Jeffrey Tan[MSFT]

Hi Brian,

Currently, we are looking for some people to handle this issue, we will
update you ASAP. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
B

Brian P. Hammer

Thanks Jeffery. In simplest terms, I need a way for my users to be able to
use a VB win form to select contact items from various private / public
folders and to link the ID to my app. In the session.addressbook, you have
ID, but this is not that same ID as the entryID.

I tried to create my own Addressbook and get the StoreID and EntryID of the
object but this is rather slow loading 1000+ contact items and even slower
when done over a slow network connection. Plus, it is prone to error using
the various samples provided on MSDN, like
(ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.KB.v10.en/enu_kbvbnetkb/vbnetkb/313800.htm)

Thanks and I'll wait to hear from you.

Regards,
Brian P. Hammer
 
P

Peter Huang [MSFT]

Hi

I think you may try to connect the outlook to database, so that we can
access to the database directly.

Connecting Outlook to Databases
http://www.outlookcode.com/d/database.htm

Accessing Microsoft Exchange and Outlook Data Using Visual Basic
http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnarout98/h
tml/olexcoutlk.asp

For detailed information, please try to post in the newsgroup below.
microsoft.public.dotnet.framework.adonet


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Brian P. Hammer

Peter - There has to be a better solution than trying to access it this way.
This is not very friendly to upgrades. Any other ideas? I have seen other
applications that do what I need. For example, Blackberry server.

Regards,
Brian
 
P

Peter Huang [MSFT]

Hi

Commonly we can use CDO to retrive the address book.
172093 How to access MAPI Address Books by using Collaboration Data Objects
1.x
http://support.microsoft.com/default.aspx?scid=kb;EN-US;172093

MAPI can be considered as the lower API for outlook, it have more advanced
application. So if the CDO can not get what we want we have to go the MAPI
way.
But it is somewhat difficult to use it in managed code directly.
Here is a link for your reference.
http://www.outlookcode.com/d/mapi.htm

Also for detailed information about MAPI
I think you need to post in the MAPI newsgroup.
microsoft.public.win32.programmer.messaging

Thanks!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang [MSFT]

Hi Brian,

How is the things going?
If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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