Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

BlackBerry Web Services

Reply
Contributor
dcousar
Posts: 11
Registered: ‎07-29-2013
My Device: BlackBerry 10
Accepted Solution

Assinging an Email Profile in VB.NET

When I try to assign an email profile to NewUserEmailProfile, I get an InvalidCastExceptionL Unable to cast object of type 'BBToolsAPI.BWSService.EmailProfile[]' to type 'BBToolsAPI.BWSService.EmailProfile'.  I'm passing an object I retrieve from: GetEmailProfilesRequest.  See code below (I made the line with the error bold):

 

    Private Function BB10AssignEmailProfile(ByVal user As Object, ByVal emlProfile As Object) As Boolean

       

        Dim returnValue As Boolean = False

        Dim request As BWSService.CreateUserEmailProfilesRequest = New BWSService.CreateUserEmailProfilesRequest()

        Dim NewUserEmailProfile As BWSService.NewUserEmailProfile = New BWSService.NewUserEmailProfile()

        NewUserEmailProfile.user = user        

        NewUserEmailProfile.emailProfile = emlProfile

       

        request.newUserEmailProfiles(0) = NewUserEmailProfile

        Dim response As BWSService.CreateUserEmailProfilesResponse = Nothing

 

        Try

            response = bwsService.createUserEmailProfiles(request)

        Catch ex As Exception

 

        End Try

 

        If (response.returnStatus.code.Equals("SUCCESS")) Then

            If Not (response.individualResponses Is Nothing) Then

                For Each individualResponse In response.individualResponses

                    '// log success for creation {0} & {1}

                Next

                returnValue = True

            End If

        Else

            If Not (response.individualResponses Is Nothing) Then

                For Each individualResponse In response.individualResponses

                    '//log response codes

                Next

 

            End If

        End If

 

        Return (returnValue)

 

    End Function

Contributor
dcousar
Posts: 11
Registered: ‎07-29-2013
My Device: BlackBerry 10

Re: Assinging an Email Profile in VB.NET

I resolved my own issue, it was looking for the Object that I set it to, to be an array value. 

 

i.e.

 

NewUserEmailProfile.emailProfile = emlProfile(0)