Reading SMTP address from Exchange Sender mail address

Discussion in 'Microsoft Outlook VBA Programming' started by VebKol, Feb 1, 2009.

  1. VebKol

    VebKol Guest

    Hi

    I'm facing problems getting SMTP address from Exchange sender mail address.
    - Using Redemption :)

    I have used this line to loop recipients
    PrSMTPAddress = &H39FE001E
    SMTPAddress =
    utils.HrGetOneProp(MailItem.Recipients(t).AddressEntry.MAPIOBJECT,
    PrSMTPAddress)

    And everything is working fine.

    But when I try to do the following :

    PrSMTPAddress = &HC1F001E
    SMTPAddress = utils.HrGetOneProp(MailItem.MAPIOBJECT, PrSMTPAddress)

    for the Exchange sender, I only get address like this :
    /O=server/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=name

    for external senders the mail address is ok :)


    Do any one have a clue ?

    --
    Regards
    OD
     
    VebKol, Feb 1, 2009
    #1
    1. Advertisements

  2. PR_SENDER_EMAIL_ADDRESS (&HC1F001E) is isn't guaranteed to be an SMTP
    address. If the sender is an internal sender you will get the Exchange DN,
    as you've seen.

    You can check to see if the address type is SMTP by checking
    PR_SENDER_ADDRTYPE (0x0C1E001E), a PT_STRING8 value. In that case you need
    to use PR_SMTP_ADDRESS (&H39FE001E).

    PR_SMTP_ADDRESS is not available in cached mode. You would use
    PR_EMS_AB_PROXY_ADDRESSES (&H800F101E) in cached mode, which is a
    PT_MV_STRING8 (string array) property.

    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007.
    Reminder Manager, Extended Reminders, Attachment Options.
    http://www.slovaktech.com/products.htm


    "VebKol" <> wrote in message
    news:...
    > Hi
    >
    > I'm facing problems getting SMTP address from Exchange sender mail
    > address.
    > - Using Redemption :)
    >
    > I have used this line to loop recipients
    > PrSMTPAddress = &H39FE001E
    > SMTPAddress =
    > utils.HrGetOneProp(MailItem.Recipients(t).AddressEntry.MAPIOBJECT,
    > PrSMTPAddress)
    >
    > And everything is working fine.
    >
    > But when I try to do the following :
    >
    > PrSMTPAddress = &HC1F001E
    > SMTPAddress = utils.HrGetOneProp(MailItem.MAPIOBJECT, PrSMTPAddress)
    >
    > for the Exchange sender, I only get address like this :
    > /O=server/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=name
    >
    > for external senders the mail address is ok :)
    >
    >
    > Do any one have a clue ?
    >
    > --
    > Regards
    > OD
     
    Ken Slovak - [MVP - Outlook], Feb 1, 2009
    #2
    1. Advertisements

  3. VebKol

    VebKol Guest

    Again Mr. Slovak : You are the KING !!!!!

    Thanks : "all" my problems are now sloved !

    :) :) :)

    --
    Regards
    OD


    "Ken Slovak - [MVP - Outlook]" wrote:

    > PR_SENDER_EMAIL_ADDRESS (&HC1F001E) is isn't guaranteed to be an SMTP
    > address. If the sender is an internal sender you will get the Exchange DN,
    > as you've seen.
    >
    > You can check to see if the address type is SMTP by checking
    > PR_SENDER_ADDRTYPE (0x0C1E001E), a PT_STRING8 value. In that case you need
    > to use PR_SMTP_ADDRESS (&H39FE001E).
    >
    > PR_SMTP_ADDRESS is not available in cached mode. You would use
    > PR_EMS_AB_PROXY_ADDRESSES (&H800F101E) in cached mode, which is a
    > PT_MV_STRING8 (string array) property.
    >
    > --
    > Ken Slovak
    > [MVP - Outlook]
    > http://www.slovaktech.com
    > Author: Professional Programming Outlook 2007.
    > Reminder Manager, Extended Reminders, Attachment Options.
    > http://www.slovaktech.com/products.htm
    >
    >
    > "VebKol" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I'm facing problems getting SMTP address from Exchange sender mail
    > > address.
    > > - Using Redemption :)
    > >
    > > I have used this line to loop recipients
    > > PrSMTPAddress = &H39FE001E
    > > SMTPAddress =
    > > utils.HrGetOneProp(MailItem.Recipients(t).AddressEntry.MAPIOBJECT,
    > > PrSMTPAddress)
    > >
    > > And everything is working fine.
    > >
    > > But when I try to do the following :
    > >
    > > PrSMTPAddress = &HC1F001E
    > > SMTPAddress = utils.HrGetOneProp(MailItem.MAPIOBJECT, PrSMTPAddress)
    > >
    > > for the Exchange sender, I only get address like this :
    > > /O=server/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=name
    > >
    > > for external senders the mail address is ok :)
    > >
    > >
    > > Do any one have a clue ?
    > >
    > > --
    > > Regards
    > > OD

    >
    >
     
    VebKol, Feb 1, 2009
    #3
  4. If you are already using Redemption, you do not need to jump through all
    these hoops, Redemption will do that for you: simply read the
    Sender.SmtpAddress property.

    --
    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/
    OutlookSpy - Outlook, CDO
    and MAPI Developer Tool
    -
    "VebKol" <> wrote in message
    news:...
    > Hi
    >
    > I'm facing problems getting SMTP address from Exchange sender mail
    > address.
    > - Using Redemption :)
    >
    > I have used this line to loop recipients
    > PrSMTPAddress = &H39FE001E
    > SMTPAddress =
    > utils.HrGetOneProp(MailItem.Recipients(t).AddressEntry.MAPIOBJECT,
    > PrSMTPAddress)
    >
    > And everything is working fine.
    >
    > But when I try to do the following :
    >
    > PrSMTPAddress = &HC1F001E
    > SMTPAddress = utils.HrGetOneProp(MailItem.MAPIOBJECT, PrSMTPAddress)
    >
    > for the Exchange sender, I only get address like this :
    > /O=server/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=name
    >
    > for external senders the mail address is ok :)
    >
    >
    > Do any one have a clue ?
    >
    > --
    > Regards
    > OD
     
    Dmitry Streblechenko, Feb 2, 2009
    #4
  5. VebKol

    juacasco Guest

    i-ve used tthe following code in outlook 2007 and i worked great!

    MsgBox fnGetSMTPAddress("/O=CNPJCO/OU=CLAC/CN=RECIPIENTS/CN=1057003")

    Public Function fnGetSMTPAddress(ExchangeMailAddress As String) As String
    Dim objOutlook As Outlook.Application
    Dim objMailItem As Outlook.MailItem

    Set objOutlook = New Outlook.Application
    Set objMailItem = objOutlook.CreateItem(0)
    objMailItem.To = ExchangeMailAddress
    objMailItem.Recipients.ResolveAll
    On Error Resume Next
    If objMailItem.Recipients.Item(1).Resolved Then
    fnGetSMTPAddress =
    objMailItem.Recipients.Item(1).AddressEntry.GetExchangeUser.PrimarySmtpAddress
    If Err.Number <> 0 Then fnGetSMTPAddress = ExchangeMailAddress
    Else
    fnGetSMTPAddress = ExchangeMailAddress
    End If
    Set objMailItem = Nothing
    Set objOutlook = Nothing

    End Function

    I hope it is useful 4 u...


    "VebKol" wrote:

    > Hi
    >
    > I'm facing problems getting SMTP address from Exchange sender mail address.
    > - Using Redemption :)
    >
    > I have used this line to loop recipients
    > PrSMTPAddress = &H39FE001E
    > SMTPAddress =
    > utils.HrGetOneProp(MailItem.Recipients(t).AddressEntry.MAPIOBJECT,
    > PrSMTPAddress)
    >
    > And everything is working fine.
    >
    > But when I try to do the following :
    >
    > PrSMTPAddress = &HC1F001E
    > SMTPAddress = utils.HrGetOneProp(MailItem.MAPIOBJECT, PrSMTPAddress)
    >
    > for the Exchange sender, I only get address like this :
    > /O=server/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=name
    >
    > for external senders the mail address is ok :)
    >
    >
    > Do any one have a clue ?
    >
    > --
    > Regards
    > OD
     
    juacasco, Mar 6, 2009
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sanjay Singh

    How to get Exchange Senders SMTP address when in OFFLINE mode

    Sanjay Singh, Oct 28, 2003, in forum: Microsoft Outlook VBA Programming
    Replies:
    0
    Views:
    363
    Sanjay Singh
    Oct 28, 2003
  2. Sanjay Singh

    Get RECIPIENTS SMTP Address when OFFLINE from Exchange Server

    Sanjay Singh, Oct 28, 2003, in forum: Microsoft Outlook VBA Programming
    Replies:
    3
    Views:
    902
    Dmitry Streblechenko
    Oct 29, 2003
  3. shaik

    reading inbox sender address

    shaik, Apr 1, 2004, in forum: Microsoft Outlook VBA Programming
    Replies:
    1
    Views:
    346
    Sue Mosher [MVP-Outlook]
    Apr 1, 2004
  4. Jeff
    Replies:
    14
    Views:
    4,939
    Olivier Lemonnier
    Jan 15, 2009
  5. Bill

    SMTP address of Exchange recipient

    Bill, Aug 8, 2007, in forum: Microsoft Outlook VBA Programming
    Replies:
    5
    Views:
    257
Loading...

Share This Page