Beginner: Need unique ID of Outlook account

G

Guest

I search a unique ID for an Outlook (2003) account (not the email address).
Even when changing machine and accessing the same (Exchange-)account, this ID
should be the same.

Details:
I have a (.net 2.0) application with a connection to a (SQL2005) database.
There are some deadlines (stored in the DB) that a user can select to
synchronize with Outlook.
If the user chooses to synchronize a deadline, I simply store the unique
Outlook entry ID in the DB, along with the Windows user SID, so that I know
for which user this deadline is synchronized.
The missing piece now is a unique ID for the Outlook account. This way I
would be able to know if the user is working on the same account (not the
email address, the "real" Outlook account) or not when logged in on another
machine.

I'm developing with Visual Studio 2005 SP1 and Office 2003 SP1 with the PIOs
installed.

Thanks for your help
 
K

Ken Slovak - [MVP - Outlook]

I don't understand what you mean by account. Is that the Outlook profile or
mailbox or what?
 
G

Guest

Hi Ken, thanks for your time.

Well what I need is to be sure that the user is accessing the same Outlook
account. I guess that would be the profile then.
 
K

Ken Slovak - [MVP - Outlook]

You cannot get that from the Outlook object model for Outlook 2003.

If you are using the Redemption MAPI library that has an
RDOSession.ProfileName property that tells you the current profile. You can
also get that information using other lower level API's such as CDO 1.21 or
Extended MAPI (C++ or Delphi only).
 
G

Guest

Thanks for your reply.
I tried using CDO 1.21 but I can't find any profile details by checking the
properties of the Session object.

Here's the code I used:
Session session = new SessionClass();
Object vEmpty = Missing.Value;
session.Logon(vEmpty, vEmpty, false, false, vEmpty, vEmpty, vEmpty);
string sessionstr = session.ToString(); //"MAPI.SessionClass"
string sessionnamestr = session.Name.ToString(); //"Outlook"
string sessioncurrentuserstr = session.CurrentUser.ToString();
//"System.__ComObject"
string sessionsessionstr = session.Session.ToString();//"MAPI.SessionClass"

Where is there any additional info regarding the profile used?
Thanks for your help
 
G

Guest

I also made the test with the Redemption MAPI:
RDOSession.ProfileName property simply returns "Outlook", like with CDO.

I don't think this is enough information for my situation. If Outlook were
connected to a (say) POP3 account rather than Exchange, would that profile
name still be "Outlook"?
 
G

Guest

OK, maybe it's easier to do it like that:
Is there any way to programmatically detect if Outlook (2003) is hooked up
to an Exchange server or not?
Also, is it possible to detect that without the annoying security message?
("allow access?" message)

Thank you
 
G

Guest

Sorry about all the messages, I just seem to make some progress:

Using the PIOs, and the Outlook.ApplicationClass object, I now found maybe
what I was looking for.
outLookApp.Session.CurrentUser.EntryID // a string
outLookApp.Session.ExchangeConnectionMode // an int (type)
The current user entry ID seems to be what I was initially looking for. The
Exchange connection mode also has a type "non-exchange" which also looks
interesting for my problem.

I still have to do some testing, if this is the real deal, but it looks very
good.
 
K

Ken Slovak - [MVP - Outlook]

No matter what store provider is used a profile name is a profile name. The
default is "Outlook" and if the user never created one with a different name
that's what you get.

The usual hack from CDO for finding out if the store is an Exchange store
would be to get the StoreID property of a folder in a store. You then
convert that hex string into ANSI characters and if inside the string is
"EMSMDB.DLL" then the store is a mailbox. For a PST file it would be
something like "mspst.dll". Do a case insensitive search for those terms.
 

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