MAPI CDO Staff Number tag?

  • Thread starter Thread starter amarmaj
  • Start date Start date
A

amarmaj

Hello,

What I need to do is to read an incoming mail, loop through all the
names in the TO list, pass these names to the GAL and extract that
users staff number.

Firstly is this possible? Can I query another users GAL details when
I'm not logged in as that user.
Secondly I'm trying to do it via Cdo/Mapi but the problem I have is
that I cannot work out what the property tag is for the Staff Number
field. I can find things like office location by using
objaddressEntry.Fields (CdoPR_OFFICE_LOCATION).Value etc but cant do it
for the staff number.

I've tried using OutlookSpy but still cant see this Staff Number tag.
Also looked on Slipstick.com, Cdolive.com

ps the Staff Number field IS populated with data for all users in the
GAL.

thanks for any help
Amar
 
(e-mail address removed) wrote in @o13g2000cwo.googlegroups.com:
Firstly is this possible? Can I query another users GAL details when
I'm not logged in as that user.

Yup, you can read the GAL just fine as long as you're logged in as
someone that can read the GAL (which is everyone, as far as I know).
ps the Staff Number field IS populated with data for all users in the
GAL.

Where are you seeing "Staff Number" in your addressbook in Outlook?
It's not a standard field, which is why it doesn't show up named as that
-- you may have to use OutlookSpy (or whatever) and search through the
fields for the one with the value that matches whatever is shown for
staff number.

You could also try making your code just dump out all the fields on the
addressbook entry in question and see if the value you're looking for
shows up there.

Third: if you want to do this when a new message arrives, are you
planning on having this running as a separate app outside Outlook that
watches the inbox, or as a macro running inside Outlook? If the former,
then you're probably better off posting to
microsoft.public.win32.programmer.messaging -- if the latter, then this
is the right group, and you can also probably do what you want without
needing to use ExMAPI/CDO, you should be able to just use Outlook
itself. (though exactly how I must admit I don't know, I don't know the
OOM too well myself)

-- dan
 
Thanks Dan,

Staff number must be one of the custom attributes but I have tried
reading values for PR_EMS_AB_EXTENSION_ATTRIBUTE_1 (1-15) but they all
error and return nothing. It must be held as something else. Strangely
it does not show up in OulookSpy either (even though it IS populated
for each user in our GAL) or maybe I'm not looking in the right places
in this v v useful tool.

Actually what I really want to do is to get all the names in an
incoming email's TO list and work out their respective SMTP addresses
(so I can send them mails at a later date. We are doing a kind of a
work flow process). I was trying to use the staff number and
concatenate it with "ourcompany.com" as this is a valid internal mail
address for us and gets away from the problem of having to resolve a
mail address from a Distinguished Name which is what my mail process
sees in the TO list)

I have just come across a bit of code from Ken Slovak's site(using
MAPI/CDO) which will indeed work out the SMTP address BUT for the
CurrentUser afaik. I need to change this function somehow to pass in
the Distinguished Names of all those in the TO list and work out their
SMTP addresses in turn. Guess this might involve making each person in
the TO list to be the CurrentUser somehow?? Will see if this is
possible but would appreciate pointers...

I propose that my code will run within Outlook.

thanks
Amar
 
It's a very easy modification.

The code is using an AddressEntry object, each Recipient object has an
AddressEntry property. Once you get each recipient from an email you can get
it as a CDO recipient and then the AddressEntry for it, then just use the
remainder of the code sample.

Are you using property tag 0x802D001E for custom attribute 1 and so on as
listed at www.cdolive.com/cdo10.htm to read the value as a string value once
you have the AddressEntry object that represents that GAL entry?
 
(e-mail address removed) wrote in @c13g2000cwb.googlegroups.com:
Strangely
it does not show up in OulookSpy either (even though it IS populated
for each user in our GAL) or maybe I'm not looking in the right places
in this v v useful tool.

You could try mdbview, that's more low-level but sometimes it's useful for
poking around; not sure why you're not finding what you're looking for.
I propose that my code will run within Outlook.

In that case I'm the wrong person to ask, sadly, but this is the right group
to be asking in, and it looks like Ken knows what's going on.

-- dan
 
Thanks Ken (and Dan). I was using the Constant and it wasnt working but
using the tag 0x802D001E it works fine.

Secondly, sorry to be a bit dense but I've tried but cant seem to make
the modification you suggest ie how to get a cdo recipient etc. (this
is my first time at coding OL)

Finally, my processses need to run without human intervantion, so do I
have to use Redemption after all if I am to avoid the Outlook msgs
about "a process trying to run code" etc
 
Redemption will avoid the security prompts if you use it correctly but
Outlook is not suitable as an object model to use for unattended execution
or for running in a Windows service. The reason is Outlook may throw up many
different warnings and dialogs, many of them modal, and you can't trap all
of them. So modal dialogs may appear that require user intervention.

For unattended execution you really should be using CDO exclusively, with
Redemption where necessary and no Outlook object model code at all.

Assuming you are getting email recipients and need the AddressEntry object.
This doesn't code things to completely avoid the Outlook object model since
I have no idea (or interest) in the rest of your code. Note that except for
the MAPI.Message no CDO is used at all and the argument for the function
could just as easily be an Outlook.MailItem

Function GetSMTP(oMail As MAPI.Message) As String
'oMail could be Outlook.MailItem with same results
Dim safMail As Redemption.SafeMailItem
Dim safAE As Redemption.AddressEntry
Dim safRecip As Redemption.SafeRecipient
Dim colRecips As Redemption.SafeRecipients
Dim strAddress As String

Const PR_EMAIL = &H39FE001E

Set safMail = CreateObject("Redemption.SafeMailItem")
safMail.Item = oMail
Set colRecips = safMail.Recipients
For Each safRecip In colRecips
If safRecip.Type = olTo Then
Set safAE = safRecip.AddressEntry
strAddress = safAE.Address
If InStr(1, strAddress, "@") > 0 Then
'got an SMTP address
Else
strAddress = safAE.Fields(PR_EMAIL)
End If

If GetSMTP = "" Then
GetSMTP = strAddress
Else 'addresses separated by semicolons
GetSMTP = GetSMTP & ";" & strAddress
End If
End If
Next

End Function
 
Ken,
Looks like Redemption is the way to go then. Thanks for the code
snippet and all your help. I really appreciate it.

Amar
 
Back
Top