Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EWS error when trying to use .ResolveName

I have a vb.net application which uses EWS to send mail. The user account has no mailbox, but has permissions to send on behalf of another mailbox. Normally this code runs fine because it has the full email address to send to, however it fails when I try to find the address by resolving the name :

When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids.

The code is as follows :

Private Function ResolveName(ByVal Name As String) As String
        Dim returnValue As NameResolutionCollection
        returnValue = _MainService.ResolveName(Name)

        Dim resolution As NameResolution

        For Each resolution In returnValue            
            Return resolution.Mailbox.Address
        Next
        Call _Owner.LogThreadMessage(frmMain.ObjectTypes.Error, "Error resolving address", Name)

        Return ""

    End Function

I think somehow it is trying to use the user account to access an address book, rather than the mailbox.

like image 494
Benno Avatar asked Dec 01 '25 04:12

Benno


1 Answers

Just incase anyone else runs into the same problem, I fixed this by looking in the directory only :

returnValue = _MainService.ResolveName(Name, ResolveNameSearchLocation.DirectoryOnly, True)

I think this is now looking at the global address list rather than in contacts, which doesn't exist.

like image 177
Benno Avatar answered Dec 02 '25 18:12

Benno



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!