Object reference not set to an instance of an object - RetrieveHeaderObject

Mar 27, 2011 at 6:45 AM
Edited Mar 27, 2011 at 6:50 AM

I always get an error for fetching headerobject both in IMAP and POP3.

could you please help me on this issue??? im spending the whole day figuring out what to do.... thanks...

Public Function RetrieveMessages(ByVal Username As String, ByVal Password As String) As ArrayList
        Dim ret As New ArrayList
        Try
            pop3client.ConnectSsl("pop.gmail.com", 995, Username, Password)

            MsgBox("You have " & pop3client.MessageCount & " messages")
            Dim index As Integer = 0

             While index <> pop3client.MessageCount
                Dim header As Header = pop3client.RetrieveHeaderObject(index + 1)
                With header
                    Dim ds() As Object = {.MessageId,.From.ToString, .Subject,.ReceivedDate}
                    ret.Add(ds)
                    index = index + 1
                End With
            End While
        Catch e As Exception
            MsgBox(e.Message)
        End Try
        Return ret
    End Function

Jun 17, 2011 at 4:01 PM

Has somebody ever workd around this issue, please . This one is killing me. though I can send mails, i cannot receive emails. it brings the system down !

 

THanks and regards

Gagan Janjua