Click here to Skip to main content
15,878,048 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In a vb application, i wanna connect via imap to a server with ssl and download new messages from an account, i was trying with Net but it doesn't allow ssl protocol, how can i?

What I have tried:

Private Sub InitializeConnection(ByVal hostname As String, ByVal port As String)
         _imapClient = New TcpClient(hostname, port)
         _imapNs = _imapClient.GetStream()
         _imapSw = New StreamWriter(_imapNs)
         _imapSr = New StreamReader(_imapNs)
     Catch ex As Exception
     End Try
 End Sub
 Private Function Response() As String
         Dim data(_imapClient.ReceiveBufferSize) As Byte
         Dim ret As Integer = _imapNs.Read(data, 0, data.Length)
         Return System.Text.Encoding.ASCII.GetString(data)
     Catch ex As Exception
     End Try
 End Function

The error is when i try an ssl authentiation, with port 25 it works.
Updated 19-Oct-22 4:01am

1 solution

Rather than trying to implement an IMAP client from scratch, I'd strongly recommend using a ready-built one.

GitHub - jstedfast/MailKit: A cross-platform .NET library for IMAP, POP3, and SMTP.[^]

This library is recommended by Microsoft, and has been thoroughly tested against multiple different servers.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900