i already know how to send a email using vb.net, however i cant figure out how to receive an email. I want to go into my email account and read a email and store it in a variable, is this possible? and if yes could any one give me some sample code, because that would be great.
just to get a good idea of what I’m using here’s my code for sending a email,
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New _
Net.NetworkCredential("trowbridge97@gmail.com", "qwerty1205")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress("trowbridge97@gmail.com")
mail.To.Add("trowbridge97@gmail.com")
mail.Subject = "Alarm"
mail.Body = "Some one is in your room"
SmtpServer.Send(mail)
MsgBox("mail send")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
SMTP is used for sending email, not receiving it.
You need a POP3 or IMAP client. There are many commercial and free .NET libraries for both protocols.