A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Getting the SMTP address from an EX address



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 24th 09, 02:45 PM posted to microsoft.public.outlook.program_vba
McKilty
external usenet poster
 
Posts: 11
Default Getting the SMTP address from an EX address

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(gsPublicCont actsFolder)

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

If UCase(SafeContact.Email1Address) UCase
") Then
SafeContact.Email1Address = ")
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.

Ads
  #2  
Old March 24th 09, 03:10 PM posted to microsoft.public.outlook.program_vba
McKilty
external usenet poster
 
Posts: 11
Default Getting the SMTP address from an EX address

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?
  #3  
Old March 24th 09, 03:14 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Getting the SMTP address from an EX address

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.Email1Entry ID)
MsgBox AE.SmtpAddress
Else
MsgBopx oContact.Email1Address
EndIf

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"McKilty" wrote in message
...
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(gsPublicCont actsFolder)

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

If UCase(SafeContact.Email1Address) UCase
") Then
SafeContact.Email1Address = ")
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.



  #4  
Old March 24th 09, 03:15 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Getting the SMTP address from an EX address

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.Email1Entry ID)
MsgBox AE.SmtpAddress
Else
MsgBopx oContact.Email1Address
EndIf

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"McKilty" wrote in message
...
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(gsPublicCont actsFolder)

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

If UCase(SafeContact.Email1Address) UCase
") Then
SafeContact.Email1Address = ")
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.




  #5  
Old March 24th 09, 06:51 PM posted to microsoft.public.outlook.program_vba
McKilty
external usenet poster
 
Posts: 11
Default Getting the SMTP address from an EX address

On Mar 24, 11:15*am, "Dmitry Streblechenko"
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.Email1Entry ID)
* MsgBox AE.SmtpAddress
Else
* MsgBopx oContact.Email1Address
EndIf

--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy *- Outlook, CDO
and MAPI Developer Tool
-"McKilty" wrote in message

...

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(gsPublicCont actsFolder)


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


If UCase(SafeContact.Email1Address) UCase
") Then
SafeContact.Email1Address = ")
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?
  #6  
Old March 24th 09, 07:00 PM posted to microsoft.public.outlook.program_vba
McKilty
external usenet poster
 
Posts: 11
Default Getting the SMTP address from an EX address

On Mar 24, 2:51*pm, McKilty wrote:
On Mar 24, 11:15*am, "Dmitry Streblechenko"
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.Email1Entry ID)
* MsgBox AE.SmtpAddress
Else
* MsgBopx oContact.Email1Address
EndIf


--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy *- Outlook, CDO
and MAPI Developer Tool
-"McKilty" wrote in message


....


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(gsPublicCont actsFolder)


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


If UCase(SafeContact.Email1Address) UCase
") Then
SafeContact.Email1Address = ")
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?
  #7  
Old March 24th 09, 07:04 PM posted to microsoft.public.outlook.program_vba
McKilty
external usenet poster
 
Posts: 11
Default Getting the SMTP address from an EX address

On Mar 24, 3:00*pm, McKilty wrote:
On Mar 24, 2:51*pm, McKilty wrote:



On Mar 24, 11:15*am, "Dmitry Streblechenko"
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.Email1Entry ID)
* MsgBox AE.SmtpAddress
Else
* MsgBopx oContact.Email1Address
EndIf


--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy *- Outlook, CDO
and MAPI Developer Tool
-"McKilty" wrote in message


....


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(gsPublicCont actsFolder)


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


If UCase(SafeContact.Email1Address) UCase
") Then
SafeContact.Email1Address = ")
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.

  #8  
Old March 24th 09, 11:15 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Getting the SMTP address from an EX address

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.Email1Entr yID)
MsgBox AE.SmtpAddress
Else
MsgBopx oContact.Email1Address
EndIf

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"McKilty" wrote in message
...
On Mar 24, 11:15 am, "Dmitry Streblechenko"
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.Email1Entry ID)
MsgBox AE.SmtpAddress
Else
MsgBopx oContact.Email1Address
EndIf

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

...

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(gsPublicCont actsFolder)


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


If UCase(SafeContact.Email1Address) UCase
") Then
SafeContact.Email1Address = ")
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?


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading SMTP address from Exchange Sender mail address VebKol Outlook and VBA 4 March 6th 09 04:08 PM
Can't get SMTP address of contact that shares email address of an Exchange user Jeff Outlook and VBA 14 January 15th 09 12:50 AM
Non-SMTP Address Louis Yeung Outlook and VBA 1 January 5th 09 07:02 PM
can not update smtp address in PAB Chris Outlook - Using Contacts 5 January 9th 08 08:59 PM
Split two smtp address John Outlook - Installation 4 May 3rd 07 06:00 PM


All times are GMT +1. The time now is 04:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.