Exchange SMTP Address

Add-in Express™ Support Service
That's what is more important than anything else

Exchange SMTP Address
 
SSL




Posts: 178
Joined: 2014-01-05
Will this work for an exchange address?

  Dim pa As Outlook.PropertyAccessor
                Const PR_SMTP_ADDRESS As String = _
                    "http://schemas.microsoft.com/mapi/proptag/0x39FE001E"
                pa = myEmail.Recipients.Item(i).PropertyAccessor

                RecipientrowTMP.Emails = pa.GetProperty(PR_SMTP_ADDRESS).ToString


It seems to work OK, just thought I would check.

Thanks
Posted 25 Feb, 2015 10:06:39 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Tom,

Sorry, I don't know the answer.


Andrei Smolin
Add-in Express Team Leader
Posted 25 Feb, 2015 11:05:23 Top
nwein




Posts: 577
Joined: 2011-03-28
This should work (though I'm not 100% sure what you're trying to do).
I did however encounter an issue with some users getting:
The property "http://schemas.microsoft.com/mapi/proptag/0x39FE001E" is unknown or cannot be found.
error.
That's why I recommend (especially if you deal with Exchange) to use https://www.add-in-express.com/creating-addins-blog/2009/05/08/outlook-exchange-email-address-smtp/ suggestion (i.e. using the mail's AddressEntry type).

Finally, you should really care about how you write your code; the example you gave chains a bunch of COM objects thus preventing you from releasing them (myEmail.Recipients.Item(i).PropertyAccessor should be broken down to r = myEmail.Recipients, j = r.Item(i), and p = j.PropertyAccessor).
Posted 25 Feb, 2015 11:54:26 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Thank you, Nir!

Tom,

Does Nir's suggestion answer your question?


Andrei Smolin
Add-in Express Team Leader
Posted 26 Feb, 2015 01:41:03 Top
SSL




Posts: 178
Joined: 2014-01-05
Hi Andrei,

I went back to the original suggestion and looked at Dimitrys Example, which I now have working for Incoming and Outgoing Email Recipients.

Only issue I have is how do I get the Exchange address of "email.SenderEmailAddress", there seems to be an issue if someone sends you an email from the same Company the sender email address looks like "/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=11A($F72FC934NOV97D038B9E4C35012-SS"

Regards,

Tom
Posted 26 Feb, 2015 04:24:51 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Posted 26 Feb, 2015 04:34:27 Top
SSL




Posts: 178
Joined: 2014-01-05
Hi Andrei,

That give me my Exchange address as the creator of the email
 ns.CurrentUser


If someone in my Company sends me an email "How do I get their Exchange Address" as they are the person sending me the email.

Regards,

Tom
Posted 26 Feb, 2015 04:39:03 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Please check Recipient.Address.


Andrei Smolin
Add-in Express Team Leader
Posted 26 Feb, 2015 05:04:25 Top
SSL




Posts: 178
Joined: 2014-01-05
Hi Andrei,

This STILL returns and converts my Exchange address! How do I convert the Exchange address of the person sending me the email?

#Region "Get Sender Exchange Address"
    Public Function fnGetSenderExchangeAddress(email As Outlook._MailItem) As String

        ' Outlook Explorer button
        Dim ns As Outlook._NameSpace = OutlookApp.Session
        If ns IsNot Nothing Then
            Try
                Dim recipients As Outlook.Recipients
                recipients = email.Recipients
                Dim Sender As Outlook.Recipient = recipients.Item(1)
                If Sender IsNot Nothing Then
                    Try
                        Dim entry As Outlook.AddressEntry = _
                            Sender.AddressEntry
                        If entry IsNot Nothing Then
                            Try
                                Dim smtpAddress As String = String.Empty
                                ' Exchange address
                                If (entry.Type = "EX") Then
                                    ' Outlook 2010
                                    If (Me.HostMajorVersion >= 14) Then
                                        fnGetSenderExchangeAddress = GetSMTPAddressViaOutlookObjectModel( _
                                            entry)
                                        Return fnGetSenderExchangeAddress
                                    Else
                                        fnGetSenderExchangeAddress = GetSMTPAddress( _
                                            entry.Address)
                                        Return fnGetSenderExchangeAddress
                                    End If
                                Else
                                    fnGetSenderExchangeAddress = entry.Address
                                    Return fnGetSenderExchangeAddress
                                End If
                            Finally
                                Marshal.ReleaseComObject(entry)
                            End Try
                        End If
                    Finally
                        Marshal.ReleaseComObject(Sender)
                    End Try
                End If
            Finally
                Marshal.ReleaseComObject(ns)
            End Try
        End If

        Return Nothing
    End Function
#End Region


Regards,

Tom
Posted 26 Feb, 2015 05:33:00 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
I see. Try using MailItem.Sender instead.


Andrei Smolin
Add-in Express Team Leader
Posted 26 Feb, 2015 06:25:17 Top