Retrieving email addresses from local outlook and / or remote microsoft exchange server

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Joerg Hamacher
Posts: 124
Joined: Thu Feb 11, 2016 12:01 am

Retrieving email addresses from local outlook and / or remote microsoft exchange server

Post by Joerg Hamacher »

Hello everybody and a happy new year to you all 8-)

a customer wants us to read out his outlook email adresses on the local PC and - even more important - to retrieve the email adresses of a microsoft exchange server that is located somewhere inside their network (can be addressed by its IP address).
I have no clue how this can be realized.
Are there any functions available in LANSA integrator or can this be managed by ActiceX-Controls in VL?
Does anybody have some experiences in this or - even better - some examples ;-)

Many thanks in advance,
Joerg
Joerg Hamacher
Posts: 124
Joined: Thu Feb 11, 2016 12:01 am

Re: Retrieving email addresses from local outlook and / or remote microsoft exchange server

Post by Joerg Hamacher »

Hello again,

no one out there with any experiences in this?

In between I found a way to retrieve the email addresses of my local MS outlook address book by creating an Microsoft Outlook Active-X control.
But I'm still fighting on how to address the remote exchange server, does anybody know if I can use the same active-x functions for that?
And I have a second problem: customer wants us to retrieve emails that are collected in a special outlook folder - but I will open a new post for that.

For those who may be interested: here comes the source code (#JH_Microsoft_Outlook is the name of the active-x control):

Code: Select all

* **************************************************
*
*  COMPONENT:  STD_FORM
*
* **************************************************
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(1285) Clientheight(744) Componentversion(2) Left(312) Top(181) Formposition(ScreenCenter) Layoutmanager(#Layout1) Theme(#SYS_THEME<2007Blue>)

Define_Com Class(#PRIM_TBLO) Name(#Layout1)
Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) Displayposition(1) Parent(#Layout1)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) Displayposition(1) Parent(#Layout1) Height(5)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row2) Displayposition(2) Parent(#Layout1) Height(5)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row3) Displayposition(3) Parent(#Layout1) Height(90)
Define_Com Class(#PRIM_TBLO.Item) Name(#STD_TEXTItem1) Manage(#STD_TEXT) Parent(#Layout1) Row(#Row1) Column(#Column1) Sizing(FitToHeight)
Define_Com Class(#PRIM_TBLO.Item) Name(#STD_NUMItem1) Manage(#STD_NUM) Parent(#Layout1) Row(#Row2) Sizing(FitToHeight) Column(#Column1) Flow(CenterHorizontal)
Define_Com Class(#PRIM_TBLO.Item) Name(#STD_NUM1Item1) Manage(#STD_NUM1) Parent(#Layout1) Row(#Row2) Sizing(FitToHeight) Column(#Column1) Flow(CenterHorizontal)
Define_Com Class(#PRIM_TBLO.Item) Name(#ListView1Item1) Manage(#ListView1) Parent(#Layout1) Row(#Row3) Column(#Column1)

Define_Com Class(#PRIM_LTVW) Name(#ListView1) Columnbuttonheight(19) Componentversion(2) Displayposition(1) Fullrowselect(True) Keyboardpositioning(SortColumn) Left(0) Parent(#COM_OWNER) Showsortarrow(True) Tabposition(1) Top(75) Height(669) Width(1285)
Define_Com Class(#PRIM_LVCL) Name(#LVCL1) Displayposition(1) Parent(#ListView1) Source(#STD_IDNO) Width(6) Captiontype(Caption)
Define_Com Class(#PRIM_LVCL) Name(#LVCL2) Displayposition(2) Parent(#ListView1) Source(#STD_INST2) Caption('Company') Captiontype(Caption) Visualstyle(#VS_EMPH) Sortonclick(True)
Define_Com Class(#PRIM_LVCL) Name(#LVCL3) Displayposition(3) Parent(#ListView1) Source(#STD_INSTR) Caption('Name') Captiontype(Caption) Sortonclick(True)
Define_Com Class(#PRIM_LVCL) Name(#LVCL4) Displayposition(4) Parent(#ListView1) Source(#STD_TEXTL) Caption('eMail') Captiontype(Caption) Width(24) Sortonclick(True)
Define_Com Class(#PRIM_LVCL) Name(#LVCL5) Displayposition(5) Parent(#ListView1) Source(#STD_TITLE) Caption('URL') Captiontype(Caption) Sortonclick(True)
Define_Com Class(#PRIM_LVCL) Name(#LVCL6) Displayposition(6) Parent(#ListView1) Source(#STD_NUML) Caption('KundenNr') Captiontype(Caption) Sortonclick(True)
Define_Com Class(#STD_NUM.Visual) Name(#STD_NUM) Componentversion(1) Displayposition(2) Height(37) Parent(#COM_OWNER) Tabposition(2) Top(38) Usepicklist(False) Width(352) Caption('Anzahl Einträge im Adressbuch:') Labeltype(Caption) Marginleft(200) Readonly(True) Left(290) Displayalignment(Center) Tabstop(False) Promptertabstop(False)
Define_Com Class(#STD_TEXT.Visual) Name(#STD_TEXT) Componentversion(1) Displayposition(3) Height(38) Parent(#COM_OWNER) Tabposition(3) Usepicklist(False) Width(400) Caption('Adressbuch:') Labeltype(Caption) Readonly(True) Left(442) Themedrawstyle('DarkTitle') Displayalignment(Center) Autoselect(False) Tabstop(False) Promptertabstop(False) Labelhoralignment(Center)
Define_Com Class(#STD_NUM.Visual) Name(#STD_NUM1) Componentversion(1) Displayposition(4) Height(37) Parent(#COM_OWNER) Tabposition(4) Top(38) Usepicklist(False) Width(352) Caption('...davon eMail-Adressen:') Labeltype(Caption) Readonly(True) Left(642) Displayalignment(Center) Tabstop(False) Promptertabstop(False)

Define_Com Class(#JH_Microsoft_Outlook.Application) Name(#JH_Microsoft_Outlook)


Evtroutine Handling(#com_owner.CreateInstance)
Set Com(#com_owner) Caption(*component_desc)
#COM_SELF.m_Load
Endroutine

Mthroutine Name(m_Load)
Define_Com Class(#JH_Microsoft_Outlook.AddressList) Name(#MyAddressList) Reference(*DYNAMIC)
Define_Com Class(#JH_Microsoft_Outlook.AddressLists) Name(#MyAddressLists) Reference(*DYNAMIC)
Define_Com Class(#JH_Microsoft_Outlook.AddressEntries) Name(#MyAddressEntries) Reference(*DYNAMIC)
Define_Com Class(#JH_Microsoft_Outlook.AddressEntry) Name(#MyAddressEntry) Reference(*DYNAMIC)

Clr_List Named(#ListView1)

* #JH_Microsoft_Outlook.CreateObject( "Outlook.Application" )

#MyAddressLists <= #JH_Microsoft_Outlook.GetNamespace( "MAPI" ).AddressLists


#MyAddressList <= #MyAddressLists.Item( 1 )
#MyAddressEntries <= #MyAddressList.AddressEntries
#STD_TEXT := #MyAddressList.Name_COM

#STD_NUM := 1
#STD_NUM1 := *Zeros
#MyAddressEntry <= #MyAddressEntries.GetFirst

Dowhile Cond(#STD_NUM <= #MyAddressList.AddressEntries.Count)

If ((#MyAddressEntry.AddressEntryUserType = "10") And (#MyAddressEntry.Type = "SMTP"))

#STD_IDNO := #STD_NUM
#STD_INST2 := #MyAddressEntry.GetContact.CompanyName
#STD_INSTR := #MyAddressEntry.GetContact.LastNameAndFirstName
#STD_TEXTL := #MyAddressEntry.Address
#STD_TITLE := #MyAddressEntry.GetContact.WebPage
#STD_NUML := #MyAddressEntry.GetContact.CustomerID.AsNumber

Add_Entry To_List(#ListView1)
#STD_NUM1 += 1
Endif

#STD_NUM += 1
#MyAddressEntry <= #MyAddressEntries.GetNext

Endwhile

Endroutine
End_Com
And this is the code of my active-x component:

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_MCCO) Progid('Outlook.Application.15') Typelibid('{00062FFF-0000-0000-C000-000000000046}9.5,0')
End_Com
Have a nice time,
Joerg
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Retrieving email addresses from local outlook and / or remote microsoft exchange server

Post by jyoung »

Hi Joerg,

Unfortunately I have never attempted anything like that before, however I have come across the POP3Service with Integrator in the documentation.

http://docs.lansa.com/14/en/lansa093/in ... ervice.htm

I think it allows receiving email, but I don't know about retrieving email addresses.

The other thing that I just thought of is if the email addresses are in a LDAP store such as ActiveDirectory or IBM Directory perhaps the OpenLDAP service
http://docs.lansa.com/14/en/lansa093/index.htm.

Since you are using an ActiveX control, it may be possible (easier) to use LDAP directly.
Post Reply