# POP3 SSL in VB.NET



## ags131 (Oct 6, 2007)

I am trying to make a auto responder email program. I need to connect to a pop server that requires SSL but the dll im usig doesnt support SSL. How can i add SSL into this? Here is a link to the DLL im using. Its open source so the code can be modified: http://www.codeproject.com/KB/IP/QMailClient.aspx

I removed the username and password.

```
Module EmailSys
    Public POP3Server = "pop.gmail.com"
    Public SMTPServer = "smtp.gmail.com"
    Public User = "Username"
    Public Pass = "Password"
    Public email() As QMailClient.EMail
    Public WithEvents pop As New QMailClient.POP3Client()
    Public smtp As New QMailClient.SMTPClient(smtpServer, User, Pass)

    Sub response(ByVal txt) Handles pop.GotResponse
        MsgBox(txt)
    End Sub

    Function getMail() As Boolean
        pop.RemoteServerAddress = POP3Server
        pop.RemoteServerPort = 995
        pop.UserName = User
        pop.Password = Pass
        pop.IncreaseNetworkCompatible = True
        If pop.Login() <> True Then GoTo errorHandler
        Dim mail As System.Collections.ArrayList = pop.GetMailList
        ReDim email(mail.Count - 1)
        Dim path = Application.StartupPath
        Dim d = System.IO.Path.DirectorySeparatorChar
        If path.EndsWith(d) = False Then path = path & d
        For I = 0 To mail.Count - 1
            email(I) = pop.RetrieveAndDeleteMail(mail(I))
            email(I).SaveToFile(path & "emails" & d & email(I).UniqueID & ".eml", True)
            email(I) = Nothing
        Next

        Return True
errorHandler:
        MsgBox("There was an error downloading the email list. Please try again later.", MsgBoxStyle.Critical, "ERROR")
    End Function


End Module
```


----------



## ags131 (Oct 6, 2007)

I found a workaround. I am using stunnel to connect gmails sll to a non ssl port on my pc. I have the pop and smtp set to localhost:110 then stunnels encrypts it to gmails ssl pop server. At the moment i have VB.net opening and closing stunnel on start and exit. If anyone knows of a better way then please tell me!


----------

