Hoe kan ik in Visual Basic 2008 een applicatie maken waarin emails kunnen worden ontvangen
van bijvoorbeeld een gmail account? Ik heb hiervoor op internet al gezocht. Nu lukt het echter wel om de afzender en het onderwerp van de email binnen te krijgen, maar nier de inhoud van de email.
(Als hij de inhoud weergeeft, krijg ik ook de html code wat niet de bedoeling is) Het gaat zich echter alleen om de inhoud.
Dit is de code die ik gebruikt heb:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' The mailman object is used for receiving (POP3)
' and sending (SMTP) email.
Dim mailman As New Chilkat.MailMan()
' Any string argument automatically begins the 30-day trial.
Dim success As Boolean
success = mailman.UnlockComponent("30-day trial")
If (success <> True) Then
MsgBox("Component unlock failed")
Exit Sub
End If
' Set the GMail account POP3 properties.
mailman.MailHost = "pop.gmail.com"
mailman.PopUsername = ""
mailman.PopPassword = ""
mailman.MailPort = "995"
mailman.PopSsl = True
Dim bundle As Chilkat.EmailBundle
' Read mail headers and one line of the body.
' To get the full emails, call CopyMail instead (no arguments)
bundle = mailman.CopyMail
If (bundle Is Nothing) Then
MsgBox(mailman.LastErrorText)
Exit Sub
End If
Dim i As Integer
Dim email As Chilkat.Email
For i = 0 To bundle.MessageCount - 1
email = bundle.GetEmail(i)
' Display the From email address and the subject.
TextBox1.Text = TextBox1.Text & email.From & vbCrLf
TextBox1.Refresh()
TextBox1.Text = TextBox1.Text & email.Subject _
& vbCrLf & vbCrLf
TextBox1.Refresh()
TextBox1.Text = TextBox1.Text.Insert = email.Body _
& vbCrLf & vbCrLf
TextBox1.Refresh()
Next
End Sub
Private Sub SendEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendEmail.Click
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
van bijvoorbeeld een gmail account? Ik heb hiervoor op internet al gezocht. Nu lukt het echter wel om de afzender en het onderwerp van de email binnen te krijgen, maar nier de inhoud van de email.
(Als hij de inhoud weergeeft, krijg ik ook de html code wat niet de bedoeling is) Het gaat zich echter alleen om de inhoud.
Dit is de code die ik gebruikt heb:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' The mailman object is used for receiving (POP3)
' and sending (SMTP) email.
Dim mailman As New Chilkat.MailMan()
' Any string argument automatically begins the 30-day trial.
Dim success As Boolean
success = mailman.UnlockComponent("30-day trial")
If (success <> True) Then
MsgBox("Component unlock failed")
Exit Sub
End If
' Set the GMail account POP3 properties.
mailman.MailHost = "pop.gmail.com"
mailman.PopUsername = ""
mailman.PopPassword = ""
mailman.MailPort = "995"
mailman.PopSsl = True
Dim bundle As Chilkat.EmailBundle
' Read mail headers and one line of the body.
' To get the full emails, call CopyMail instead (no arguments)
bundle = mailman.CopyMail
If (bundle Is Nothing) Then
MsgBox(mailman.LastErrorText)
Exit Sub
End If
Dim i As Integer
Dim email As Chilkat.Email
For i = 0 To bundle.MessageCount - 1
email = bundle.GetEmail(i)
' Display the From email address and the subject.
TextBox1.Text = TextBox1.Text & email.From & vbCrLf
TextBox1.Refresh()
TextBox1.Text = TextBox1.Text & email.Subject _
& vbCrLf & vbCrLf
TextBox1.Refresh()
TextBox1.Text = TextBox1.Text.Insert = email.Body _
& vbCrLf & vbCrLf
TextBox1.Refresh()
Next
End Sub
Private Sub SendEmail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendEmail.Click
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class