djfistic

How to get alias of outlook's contacts

8 posts in this topic

#1 ·  Posted (edited)

Dear all,

I would like to get all Outlook's contacts with the fields  (EmailAdddress,name and (alias) sn, in one Exchange AdressList selected.

I'm with Outlook 2016 with an Exchange account. I have no rights on AD servers, I'm a simple user.

For the moment I can get all accounts with the "outlook udf" , but the "sn" propertie is not included. I'm a bit stuck.

After several tries, I don't have any ideas to get it ?? I can see no options in the udf.

Do you have any ideas ?

Test.au3

Edited by djfistic

Share this post


Link to post
Share on other sites



#2 ·  Posted

Did you try the new OutlookEX UDF? Link is in my signature.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

Hello water,

Thank you for your answer,I updated the udf, but it the same. Is there some possibilities with the udf to get properties such postal code, country of an user ? if yes, the alias propertie is maybe in the same place.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Can you please post the script you use?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

#include <OutlookEX.au3>

; *****************************************************************************
; Open Outlook instance
; *****************************************************************************
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

; List all adress lists
; *****************************************************************************
$aResult = _OL_AddressListGet($oOutlook, False)
If @error <> 0 Then _
    Exit MsgBox(16, "OutlookEX UDF: _OL_AddressListGet Example Script", "Error " & @error & " when listing all address lists!")
_ArrayDisplay($aResult, "OutlookEX UDF: _OL_AddressListGet Example Script - All address lists", "", 0, "|", "OlAddressListType|Name|Index|Resolving order|Identifier")

; Keep list who contains the word
Local $sSearchList="SAS"

If IsArray($aResult) Then
    Local $index=_ArraySearch($aResult, $sSearchList, 0, 0, 0, 1, 0)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Not Found",$sSearchList & " was not found")
    Else
        MsgBox($MB_SYSTEMMODAL, "Found",  $sSearchList & "was found in the array at position " & $index )
        ; Get all List members with my var $sSearchList filter
        $aResult = _OL_AddressListMemberGet($oOutlook, $aResult[$index][1])
        If @error <> 0 Then _
            Exit MsgBox(16, "OutlookEX UDF: _OL_AddressListMemberGet Example Script", "Error " & @error & " gettings members of first address lists!")
            _ArrayDisplay($aResult, "OutlookEX UDF: _OL_AddressListMemberGet Example Script - All members of the first address list", "", 0, "|", "EMail address|Name|OlAddresEntryUserType|Identifier|Object of the address entry")
        EndIf
    EndIf

_OL_Close($oOutlook)

Here is my actual code.

Share this post


Link to post
Share on other sites

#6 ·  Posted

Element 4 of each array row contains the contact object. The possible properties you can retrieve can be found here: https://msdn.microsoft.com/de-de/library/ff867603.aspx

Example: $aResult[1][4].LastName returns the lastname of the first contact.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted

Dear water,

Thanks to you, it works fine now. Thanks a lot

For get the Alias property, you must set the variable to .Alias

$aResult[1][4].Alias

See bellow the final code who works .

#include <OutlookEX.au3>
#include <Array.au3>

; *****************************************************************************
; Open Outlook instance
; *****************************************************************************
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

; List all address lists
; *****************************************************************************
$aResult = _OL_AddressListGet($oOutlook, False)
If @error <> 0 Then _
    Exit MsgBox(16, "OutlookEX UDF: _OL_AddressListGet Example Script", "Error " & @error & " when listing all address lists!")
_ArrayDisplay($aResult, "OutlookEX UDF: _OL_AddressListGet Example Script - All address lists", "", 0, "|", "OlAddressListType|Name|Index|Resolving order|Identifier")

; Keep list who contains the word
Local $sSearchList="SAS"
; Set an array for all aliases
Local $aAliases[0]

If IsArray($aResult) Then
    Local $index=_ArraySearch($aResult, $sSearchList, 0, 0, 0, 1, 0)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Not Found","List who contain the word : "& $sSearchList & " was not found in all address list !")
    Else
        MsgBox($MB_SYSTEMMODAL, "Found","List who contain the word : "&  $sSearchList & " was found in the array at position " & $index )
        ; Get all List members with my var $sSearchList
        $aResult = _OL_AddressListMemberGet($oOutlook, $aResult[$index][1])
        If @error <> 0 Then _
            Exit MsgBox(16, "OutlookEX UDF: _OL_AddressListMemberGet Example Script", "Error " & @error & " gettings members of first address lists!")
            _ArrayDisplay($aResult, "OutlookEX UDF: _OL_AddressListMemberGet Example Script - All members of the first address list", "", 0, "|", "EMail address|Name|OlAddresEntryUserType|Identifier|Object of the address entry")
            For $cpt=1 To UBound($aResult)-1
                Local $sCurrentALias=$aResult[$cpt][4].Alias
                ConsoleWrite("Current alias : " &$sCurrentALias &@CRLF)
                If $sCurrentALias<>"" Then _ArrayAdd($aAliases,$sCurrentALias)
            Next
            If UBound($aAliases) > 0 Then _ArrayDisplay($aAliases,"All aliases")
        EndIf
EndIf

_OL_Close($oOutlook)

 

Share this post


Link to post
Share on other sites

#8 ·  Posted

Glad you got it working :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now