Getting the SMTP address from an EX address

M

McKilty

I've written code to compare our Public Folder Recipients List with
information we have in several databases. The program will update the
Public Folders with the information in the database.

The snag I've hit is with the e-mail address. I am using Outlook
Redemption and retrieving Email1Address but the type is EX and what we
have in the database is SMTP.

My applicable code, which will fail because of this, is:

-------------------------------------------------------------------------------
Dim myFolder As outlook.MAPIFolder
Dim myInbox As outlook.MAPIFolder
Dim myNameSpace As outlook.NameSpace
Dim myOutlook As outlook.Application
Dim SafeContact, oContact

Set myOutlook = CreateObject("Outlook.Application." & Val(Left
(outlook.Version, 2)))
Set myNameSpace = myOutlook.GetNamespace("MAPI")
myNameSpace.Logon
Set myFolder = myNameSpace.Folders("Public Folders").Folders("All
Public Folders").Folders("Contacts").Folders(gsPublicContactsFolder)

Set SafeContact = CreateObject("Redemption.SafeContactItem")
Set oContact = myFolder.Items.Find("[EMPID2] = 472")

If UCase(SafeContact.Email1Address) <> UCase
("(e-mail address removed)") Then
SafeContact.Email1Address = ("(e-mail address removed)")
End If
-------------------------------------------------------------------------------


It's off because some addresses are EX and some are SMTP, yet all are
employees so I would have thought they'd all be the same.

I tried writing code to handle this, but then some of the EX types
have a string of numbers after the name. For example:

[snip]/cn=Recipients/cn=rbray
[snip]/cn=Recipients/cn=bmarshall21766933

Those numbers don't appear anywhere in the SMTP address and even when
you click on the properties and view the EX, you don't see those
numbers.
 
M

McKilty

I'm also wondering if the reason some are SMTP and some are EX is
because how they were entered. If the e-mail is written in by hand,
it would be SMTP, but if it was chosen with address book, it would be
the EX type. Is this correct?
 
D

Dmitry Streblechenko

Try something like the following

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
...
if oContact.Email1AddressType = "EX Then
set AE = Session.GetAddressEntryFromID(oContact.Email1EntryID)
MsgBox AE.SmtpAddress
Else
MsgBopx oContact.Email1Address
EndIf

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
D

Dmitry Streblechenko

Try something like the following

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
...
if oContact.Email1AddressType = "EX Then
set AE = Session.GetAddressEntryFromID(oContact.Email1EntryID)
MsgBox AE.SmtpAddress
Else
MsgBopx oContact.Email1Address
EndIf

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
M

McKilty

Try something like the following

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
..
if oContact.Email1AddressType = "EX Then
  set AE = Session.GetAddressEntryFromID(oContact.Email1EntryID)
  MsgBox AE.SmtpAddress
Else
  MsgBopx oContact.Email1Address
EndIf

--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

I've written code to compare our Public Folder Recipients List with
information we have in several databases.  The program will update the
Public Folders with the information in the database.
The snag I've hit is with the e-mail address.  I am using Outlook
Redemption and retrieving Email1Address but the type is EX and what we
have in the database is SMTP.
My applicable code, which will fail because of this, is:
-------------------------------------------------------------------------------
Dim myFolder As outlook.MAPIFolder
Dim myInbox As outlook.MAPIFolder
Dim myNameSpace As outlook.NameSpace
Dim myOutlook As outlook.Application
Dim SafeContact, oContact
Set myOutlook = CreateObject("Outlook.Application." & Val(Left
(outlook.Version, 2)))
Set myNameSpace = myOutlook.GetNamespace("MAPI")
myNameSpace.Logon
Set myFolder = myNameSpace.Folders("Public Folders").Folders("All
Public Folders").Folders("Contacts").Folders(gsPublicContactsFolder)
Set SafeContact = CreateObject("Redemption.SafeContactItem")
Set oContact = myFolder.Items.Find("[EMPID2] = 472")
If UCase(SafeContact.Email1Address) <> UCase
("(e-mail address removed)") Then
SafeContact.Email1Address = ("(e-mail address removed)")
End If
-------------------------------------------------------------------------------
It's off because some addresses are EX and some are SMTP, yet all are
employees so I would have thought they'd all be the same.
I tried writing code to handle this, but then some of the EX types
have a string of numbers after the name.  For example:
[snip]/cn=Recipients/cn=rbray
[snip]/cn=Recipients/cn=bmarshall21766933

Those numbers don't appear anywhere in the SMTP address and even when
you click on the properties and view the EX, you don't see those
numbers.

Thanks Dmitry.

When I throw that in the code, it halts and highlights MAPIOBJECT.
The error it throws is:

Compile Error
Method or data member not found.

Maybe I have an old version of your software. I have: 4.0.0.452.


Assuming that I update the software, would this have an effect on
existing software that used the version I have now?
 
M

McKilty

Try something like the following
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
..
if oContact.Email1AddressType = "EX Then
  set AE = Session.GetAddressEntryFromID(oContact.Email1EntryID)
  MsgBox AE.SmtpAddress
Else
  MsgBopx oContact.Email1Address
EndIf
--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool
news:5ca1b612-fd08-4909-9850-217be7dd8779@j39g2000yqn.googlegroups.com....
I've written code to compare our Public Folder Recipients List with
information we have in several databases.  The program will update the
Public Folders with the information in the database.
The snag I've hit is with the e-mail address.  I am using Outlook
Redemption and retrieving Email1Address but the type is EX and what we
have in the database is SMTP.
My applicable code, which will fail because of this, is:
-------------------------------------------------------------------------------
Dim myFolder As outlook.MAPIFolder
Dim myInbox As outlook.MAPIFolder
Dim myNameSpace As outlook.NameSpace
Dim myOutlook As outlook.Application
Dim SafeContact, oContact
Set myOutlook = CreateObject("Outlook.Application." & Val(Left
(outlook.Version, 2)))
Set myNameSpace = myOutlook.GetNamespace("MAPI")
myNameSpace.Logon
Set myFolder = myNameSpace.Folders("Public Folders").Folders("All
Public Folders").Folders("Contacts").Folders(gsPublicContactsFolder)
Set SafeContact = CreateObject("Redemption.SafeContactItem")
Set oContact = myFolder.Items.Find("[EMPID2] = 472")
If UCase(SafeContact.Email1Address) <> UCase
("(e-mail address removed)") Then
SafeContact.Email1Address = ("(e-mail address removed)")
End If
-------------------------------------------------------------------------------
It's off because some addresses are EX and some are SMTP, yet all are
employees so I would have thought they'd all be the same.
I tried writing code to handle this, but then some of the EX types
have a string of numbers after the name.  For example:
[snip]/cn=Recipients/cn=rbray
[snip]/cn=Recipients/cn=bmarshall21766933
Those numbers don't appear anywhere in the SMTP address and even when
you click on the properties and view the EX, you don't see those
numbers.

Thanks Dmitry.

When I throw that in the code, it halts and highlights MAPIOBJECT.
The error it throws is:

Compile Error
Method or data member not found.

Maybe I have an old version of your software.  I have: 4.0.0.452.

Assuming that I update the software, would this have an effect on
existing software that used the version I have now?

I made a backup of the original and downloaded the ner version
(4.7.0.1026). It behaves the same way and doesn't know what
MAPIOBJECT is.

Am I taking your code too literal?
 
M

McKilty

On Mar 24, 11:15 am, "Dmitry Streblechenko" <[email protected]>
wrote:
Try something like the following
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
..
if oContact.Email1AddressType = "EX Then
  set AE = Session.GetAddressEntryFromID(oContact.Email1EntryID)
  MsgBox AE.SmtpAddress
Else
  MsgBopx oContact.Email1Address
EndIf
--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

I've written code to compare our Public Folder Recipients List with
information we have in several databases.  The program will update the
Public Folders with the information in the database.
The snag I've hit is with the e-mail address.  I am using Outlook
Redemption and retrieving Email1Address but the type is EX and whatwe
have in the database is SMTP.
My applicable code, which will fail because of this, is:
-------------------------------------------------------------------------------
Dim myFolder As outlook.MAPIFolder
Dim myInbox As outlook.MAPIFolder
Dim myNameSpace As outlook.NameSpace
Dim myOutlook As outlook.Application
Dim SafeContact, oContact
Set myOutlook = CreateObject("Outlook.Application." & Val(Left
(outlook.Version, 2)))
Set myNameSpace = myOutlook.GetNamespace("MAPI")
myNameSpace.Logon
Set myFolder = myNameSpace.Folders("Public Folders").Folders("All
Public Folders").Folders("Contacts").Folders(gsPublicContactsFolder)
Set SafeContact = CreateObject("Redemption.SafeContactItem")
Set oContact = myFolder.Items.Find("[EMPID2] = 472")
If UCase(SafeContact.Email1Address) <> UCase
("(e-mail address removed)") Then
SafeContact.Email1Address = ("(e-mail address removed)")
End If
-------------------------------------------------------------------------------
It's off because some addresses are EX and some are SMTP, yet all are
employees so I would have thought they'd all be the same.
I tried writing code to handle this, but then some of the EX types
have a string of numbers after the name.  For example:
[snip]/cn=Recipients/cn=rbray
[snip]/cn=Recipients/cn=bmarshall21766933
Those numbers don't appear anywhere in the SMTP address and even when
you click on the properties and view the EX, you don't see those
numbers.
Thanks Dmitry.
When I throw that in the code, it halts and highlights MAPIOBJECT.
The error it throws is:
Compile Error
Method or data member not found.
Maybe I have an old version of your software.  I have: 4.0.0.452.
Assuming that I update the software, would this have an effect on
existing software that used the version I have now?

I made a backup of the original and downloaded the ner version
(4.7.0.1026).  It behaves the same way and doesn't know what
MAPIOBJECT is.

Am I taking your code too literal?

I changed the code a bit so that it reads as such:

Set Session = CreateObject("Redemption.RDOSession")
Session.Folders("Public Folders").Folders("All Public Folders").Folders
("Contacts").Folders(gsPublicContactsFolder) =
Application.Session.MAPIOBJECT

I know the second MAPIOBJECT is going to cause a problem, but it
breaks on the first line with the error:

Property is read-only.
 
D

Dmitry Streblechenko

Sorry, replace Application (which most likely points to an instance of
Access.Application rather than Outlook.Application) with myOutlook :

set rSession = CreateObject("Redemption.RDOSession")
rSession.MAPIOBJECT = myOutlook .Session.MAPIOBJECT
...
if oContact.Email1AddressType = "EX Then
set AE = rSession.GetAddressEntryFromID(oContact.Email1EntryID)
MsgBox AE.SmtpAddress
Else
MsgBopx oContact.Email1Address
EndIf

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Try something like the following

set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
..
if oContact.Email1AddressType = "EX Then
set AE = Session.GetAddressEntryFromID(oContact.Email1EntryID)
MsgBox AE.SmtpAddress
Else
MsgBopx oContact.Email1Address
EndIf

--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

I've written code to compare our Public Folder Recipients List with
information we have in several databases. The program will update the
Public Folders with the information in the database.
The snag I've hit is with the e-mail address. I am using Outlook
Redemption and retrieving Email1Address but the type is EX and what we
have in the database is SMTP.
My applicable code, which will fail because of this, is:
-------------------------------------------------------------------------------
Dim myFolder As outlook.MAPIFolder
Dim myInbox As outlook.MAPIFolder
Dim myNameSpace As outlook.NameSpace
Dim myOutlook As outlook.Application
Dim SafeContact, oContact
Set myOutlook = CreateObject("Outlook.Application." & Val(Left
(outlook.Version, 2)))
Set myNameSpace = myOutlook.GetNamespace("MAPI")
myNameSpace.Logon
Set myFolder = myNameSpace.Folders("Public Folders").Folders("All
Public Folders").Folders("Contacts").Folders(gsPublicContactsFolder)
Set SafeContact = CreateObject("Redemption.SafeContactItem")
Set oContact = myFolder.Items.Find("[EMPID2] = 472")
If UCase(SafeContact.Email1Address) <> UCase
("(e-mail address removed)") Then
SafeContact.Email1Address = ("(e-mail address removed)")
End If
-------------------------------------------------------------------------------
It's off because some addresses are EX and some are SMTP, yet all are
employees so I would have thought they'd all be the same.
I tried writing code to handle this, but then some of the EX types
have a string of numbers after the name. For example:
[snip]/cn=Recipients/cn=rbray
[snip]/cn=Recipients/cn=bmarshall21766933

Those numbers don't appear anywhere in the SMTP address and even when
you click on the properties and view the EX, you don't see those
numbers.

Thanks Dmitry.

When I throw that in the code, it halts and highlights MAPIOBJECT.
The error it throws is:

Compile Error
Method or data member not found.

Maybe I have an old version of your software. I have: 4.0.0.452.


Assuming that I update the software, would this have an effect on
existing software that used the version I have now?
 

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