1
Vote

Cannot read Gmail using Imap4Client

description

The code below fails when it tries to run "imap.ConnectSsl"...any ideas?
The error message is "Unexpected end of stream".

Thanks,
Paul de Prado

Imports System.Text
Imports ActiveUp.Net.Imap4
Imports ActiveUp.Net.Mail
Imports ActiveUp.Net.Dns
Imports ActiveUp.Net.Groupware
Imports ActiveUp.Net.OpenPGP
Imports ActiveUp.Net.Security
Imports ActiveUp.Net.WhoIs
Public Sub Main()
    Try

        Dim imap As New Imap4Client
        imap.ConnectSsl("pop.gmail.com", 995)
        imap.Login("myaccount@gmail.com", "mypassword")
        Dim inbox As Mailbox = imap.SelectMailbox("inbox")
        imap.Disconnect()

    Catch e As Exception 'general programming error
        MsgBox(e.Message, _
        MsgBoxStyle.OkOnly Or MsgBoxStyle.Exclamation, _
            "Error Encountered")
    End Try


End Sub

comments

jstedfast wrote Oct 31, 2015 at 1:07 PM

First, I would recommend using MailKit instead.

That said, the problem is that you are connecting the Imap4Client to a POP3 server & port instead of an IMAP server.

Try this instead:
imap.ConnectSsl("imap.gmail.com", 993)

Hope that helps.