Solved

Problem retrieving NT account details from CDO

Posted on 2001-06-27
12
574 Views
Last Modified: 2013-11-13
I'm currently writing a Visual Basic component which references CDO for a corporate intranet.

One of the methods of my component will be used to search within the Global Address List for a specific NT user so that I can retrieve their SMTP address & send them emails.

Everything was going fine with writing this component, I can start and log into a MAPI session & gain access to the 'Global Address List' but I am now having problems using one of the MAPI property tags called PR_EMS_AB_ASSOC_NT_ACCOUNT.

I have seen an MSDN article where PR_EMS_AB_ASSOC_NT_ACCOUNT is defined as a
cdo constant - CdoPR_EMS_AB_ASSOC_NT_ACCOUNT with value &H80270102.

Unfortunately, whenever I try & gain access to this property using the 'fields' collection of the AddressEntry object ...

Private Const CdoPR_EMS_AB_ASSOC_NT_ACCOUNT = &H80270102

....

strSID = objAddressEntry.Fields CdoPR_EMS_AB_ASSOC_NT_ACCOUNT).Value

... I get a 'MAPI_E_NOT_FOUND' error. I guess this
is because CDO cannot locate the PR_EMS_AB_ASSOC_NT_ACCOUNT  property within
the AddressEntry object despite the documentation within MSDN which suggests otherwise! Please can somebody tell me what I might be doing wrong, or perhaps there is another way to approach this problem?

Thanks


Jon
0
Comment
Question by:jgianni
12 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 6234103
I don't think the value is &H80270102, but &H8027 or &H80270000. Could you try that?

Regards,
CJ
0
 

Author Comment

by:jgianni
ID: 6234281
Thanks. Just tried both of those values but neither worked - received the same error message - MAPI_E_NOT_FOUND.

MSDN documentation *does* state the value for PR_EMS_AB_ASSOC_NT_ACCOUNT as &H80270102 in a number of different places.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6234287
Okay,
could you show some source code of yourself? Including the language you are using (I think you are using VB)...just wanna be sure. if you can show some source, I can try and debug.

regards,
CJ
0
 

Author Comment

by:jgianni
ID: 6234407
Private mobjSession As MAPI.Session

'This constant is not defined by CDO (1.2, 1.21)
Private Const CdoPR_EMS_AB_ASSOC_NT_ACCOUNT = &H80270102

Public Function GetSMTPAddress(ByVal vstrUserName As String, ByVal vstrProfileName As String)
   
   ' variable declarations    
    Dim i As Long 'array index
    Dim n As Long ' array index
    Dim objAddressEntry As AddressEntry
    Dim objGlobalAddressList As AddressList
    Dim strSID As String ' sid
     
    ' Log on to a MAPI session
    Call Session_Logon(vstrProfileName)
   
    ' set a reference to the global address list
    Set objGlobalAddressList = GetGlobalAddressList
   
    ' loop through global address list
    For i = 1 To objGlobalAddressList.AddressEntries.Count
   
    Set objAddressEntry = objGlobalAddressList.AddressEntries(i)
       
    ' everything works until here - when I attempt to retrieve the SID
    strSID = objAddressEntry.Fields.Item(CdoPR_EMS_AB_ASSOC_NT_ACCOUNT).Value


0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6234519
I'm kinda ashaimed to ask, but what component did you exactly use that you couldget the MAPI ? I found the CDO libraries for NT and 2000, but neither one of them has those. Next to that i treid the MAPISession control,m which supplied me with almost the same items as you have in your code, but it's not the way to go if I have to follow your way (which I also would like to use).

One thing I found in the documentation is that the PR_EMS_AB_ASSOC_NT_ACCOUNT may not be supported by the underlaying system.

Anyway, before I know the correct reference I cannot debug the code...:-/

regards,
CJ
0
 

Author Comment

by:jgianni
ID: 6234554
Sorry, I omitted a couple of functions that I use to log on to a MAPI session & to retrieve the global address list. Both of these functions work as required, but it's not final code yet so it may be a bit messy.

The CDO library that I am using is 1.21 & I am using Visual Basic 6 SP5.

' Function: Session_Logon_NoDialog
' Purpose: Login to a MAPI session using the given profile name

Private Sub Session_Logon(ByVal vstrProfileName As String)

    On Error GoTo error_olemsg
   
    Set mobjSession = New MAPI.Session
   
    If TypeName(mobjSession) <> "" Then
        mobjSession.Logon vstrProfileName, , False, False
    End If
    Exit Sub

error_olemsg:

    If 1273 = Err Then ' VB4.0: If Err.Number = CdoE_LOGON_FAILED Then
        Err.Raise vbObjectError + 1, "JDWEmailInfo", "Cannot logon: incorrect profile name or password"
        Exit Sub
    End If
   
    Err.Raise vbObjectError + 2, "JDWEmailInfo", "Error " & Str(Err) & ": " & Error$(Err)
    Resume Next
   
End Sub

' Function: GetGlobalAddressList
' Purpose: retrieve the global address list

Private Function GetGlobalAddressList() As AddressList
   
    On Error GoTo err_GetGlobalAddressList
 
    If mobjSession Is Nothing Then
        Err.Raise vbObjectError + 3, "JDWEmailInfo", "No active session has been created."
        Exit Function
    End If
   
    Set GetGlobalAddressList = mobjSession.AddressLists("Global Address List")
   
    Exit Function
 
err_GetGlobalAddressList:
   
    Err.Raise vbObjectError + 5, "JDWEmailInfo", "Unrecoverable Error:" & Err
   
    Exit Function
   
End Function
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 22

Expert Comment

by:CJ_S
ID: 6244220
Been trying to, even installed SP5 but still don't have the MAPI libraries (CDO)...I guess I cannot help / test due to not being able to find the correct reference.

Sorry...

regards,
CJ

(ps. unless you can send me a sample VB project with the reference already set...)
0
 

Author Comment

by:jgianni
ID: 6244926
i think the problem here is to do with an incorrect hex value. i'll give you the points if you can find out what the value is supposed to be!!!

the only msdn documentation that i could find:

"A property tag is a 32-bit number that contains a unique property identifier in bits 16 through 31 and a property type in bits 0 through 15"

remember 'treasure hunt' with anneka rice? this is what this is like!! ;-)
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6244960
Either that ot it just is not supported.

This is what i found:
Public Const PR_EMS_AB_ASSOC_NT_ACCOUNT = &H80270102

Maybe you find the following link useful:
http://www.outlookexchange.com/Articles/home/outlookcodeexample.asp

They have quite some development articles :-/

Regards,
CJ
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6244970
Nice comparison btw :-)
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7466858

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 7505173
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now