Return the ID property of an outbound email - VB.NET

Oct 7, 2013 at 8:11 PM
I need to capture the ID of an outbound email when it's sent, so I can record opens, clicks, etc on the back end for each specific email sent. I am having trouble retrieving the ID through code. See code below - I get an error message "'ID' is not a member of 'MailChimp.Types.MVList(Of MailChimp.Types.Mandrill.Messages.SendResult)'". Please help!!
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
    Try
        Dim strMandrillKey As String = My.Settings.Mandrill_API_Key
        Dim mail As MailChimp.MandrillApi = New MailChimp.MandrillApi(strMandrillKey)

        Dim msg As New MailChimp.Types.Mandrill.Messages.Message
        Dim result As New MailChimp.Types.MVList(Of MailChimp.Types.Mandrill.Messages.SendResult)

        Dim recipient As New MailChimp.Types.Mandrill.Messages.Recipient(txtTo.Text, "")
        Dim aRecipients(0) As MailChimp.Types.Mandrill.Messages.Recipient
        aRecipients(0) = recipient

        With msg
            .FromEmail = txtFrom.Text
            .Subject = txtSubject.Text
            .Text = txtBody.Text
            .To = aRecipients
        End With

        result = mail.Send(msg)

        txtResult.Text = result.ID


        'MsgBox("Ping: " & mail.Ping())
    Catch ex As MailChimp.Types.MCException
        MsgBox(ex.Message)
    End Try

End Sub
Coordinator
Oct 10, 2013 at 9:24 PM
Your result var. is a list of SendResults. So, if u need ID u should iterate through this collection (result[0].ID in C#)
Marked as answer by mholliday on 10/11/2013 at 8:07 AM
Oct 11, 2013 at 3:07 PM
Got it! Thanks, denisk1981! Functional code posted below for anyone who might be interested.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
    Try
        Dim strMandrillKey As String = My.Settings.Mandrill_API_Key
        Dim mail As MailChimp.MandrillApi = New MailChimp.MandrillApi(strMandrillKey)

        Dim msg As New MailChimp.Types.Mandrill.Messages.Message
        Dim resultDetails(0) As MailChimp.Types.Mandrill.Messages.SendResult
        Dim result As MailChimp.Types.MVList(Of MailChimp.Types.Mandrill.Messages.SendResult)

        Dim recipient As New MailChimp.Types.Mandrill.Messages.Recipient(txtTo.Text, "")
        Dim aRecipients(0) As MailChimp.Types.Mandrill.Messages.Recipient
        aRecipients(0) = recipient

        With msg
            .FromEmail = txtFrom.Text
            .Subject = txtSubject.Text
            .Text = txtBody.Text
            .To = aRecipients
        End With

        result = mail.Send(msg)

        txtResult.Text = result(0).ID

    Catch ex As MailChimp.Types.MCException
        MsgBox(ex.Message)
    End Try

End Sub