Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Access HTML Email Body and/or Plain-Text Email Body
This example demonstrates how to access either the HTML body (source) of an email, the plain-text email body, or both.
' Visual Basic example to read mail from a POP3 server
' and display the plain-text body and/or the HTML body source
' This example leaves the mail on the POP3 server.
Private Sub Command1_Click()
' Create the mail object for sending email.
Dim mailman As ChilkatMailMan2
Set mailman = New ChilkatMailMan2
' Anything begins the 30-day trial.
mailman.UnlockComponent "UnlockCode"
' Set our POP3 hostname an login / password
mailman.MailHost = "mail.chilkatsoft.com"
mailman.PopUsername = "myLogin"
mailman.PopPassword = "myPassword"
' Read email from the POP3 server into a mail bundle.
' Call TransferMail instead of CopyMail to transfer
' it from the POP3 server instead of leaving it on the
' POP3 server.
Dim bundle As ChilkatEmailBundle2
Set bundle = mailman.CopyMail
If (bundle Is Nothing) Then
MsgBox mailman.LastErrorText
Exit Sub
End If
' Loop over each mail message in the bundle
MessageCount = bundle.MessageCount
Dim i As Long
Dim email As ChilkatEmail2
For i = 0 To MessageCount - 1
Set email = bundle.GetEmail(i)
LogWindow.Text = LogWindow.Text & "Message #" & (i + 1) & vbCrLf
' Display the HTML source of the HTML body if it exists.
If email.HasHtmlBody() Then
LogWindow.Text = LogWindow.Text & "HTML Source: " & email.GetHtmlBody() & vbCrLf
End If
' Display the plain-text body, if it exists.
If email.HasPlainTextBody() Then
LogWindow.Text = LogWindow.Text & "Plain-Text Body: " & email.GetPlainTextBody() & vbCrLf
End If
Set email = Nothing
LogWindow.Text = LogWindow.Text & "-------------------------" & vbCrLf
Next
End Sub
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.