VB.NET Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
PFX
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

Read and Forward POP3 Email

Download Chilkat .NET for 4.0 Framework

Download Chilkat .NET for 64-bit 4.0 Framework (x64)

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 64-bit 2.0 / 3.5 Framework (x64)

Download Chilkat .NET for 1.0 / 1.1 Framework

Read a POP3 mailbox, removes any XML file attachments, and forwards the email to another email account.

'  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 POP3 server's hostname
mailman.MailHost = "mail.chilkatsoft.com"

'  Set the POP3 login/password.
mailman.PopUsername = "matt@chilkatsoft.com"
mailman.PopPassword = "*myPassword2*"

Dim bundle As Chilkat.EmailBundle

'  Copy the all email from the user's POP3 mailbox
'  into a bundle object.  The email remains on the server.
bundle = mailman.CopyMail()

If (bundle Is Nothing ) Then
    MsgBox(mailman.LastErrorText)
    Exit Sub
End If


'  Set the SMTP hostname for sending.
mailman.SmtpHost = "smtp.comcast.net"
'  Set your SmtpUsername/Password for authentication if necessary.
'  This example assumes that SMTP authentication is not needed.

Dim i As Long
Dim email As Chilkat.Email
For i = 0 To bundle.MessageCount - 1
    email = bundle.GetEmail(i)

    TextBox1.Text = TextBox1.Text & email.From & vbCrLf
    TextBox1.Refresh()
    TextBox1.Text = TextBox1.Text & email.Subject _
         & vbCrLf & vbCrLf
    TextBox1.Refresh()

    '  Loop over the attachment filenames.  Drop any
    '  ending in .xml
    Dim numAttach As Long
    Dim j As Long
    numAttach = email.NumAttachments
    For j = 0 To numAttach - 1
        Dim fname As String
        fname = email.GetAttachmentFilename(j)
        TextBox1.Text = TextBox1.Text & fname & vbCrLf
        TextBox1.Refresh()
        '  If the fname ends in .xml, we would call
        '  email.DropSingleAttachment(j);
        '  You would also want to decrement numAttach
        '  and decrement j before the next loop iteration.
    Next

    '  Clear the To and CC email recipients.
    email.ClearTo()
    email.ClearCC()

    '  Add the recipient to receive the forwarded email:
    email.AddTo("Chilkat Support","support@chilkatsoft.com")

    '  Send the email
    success = mailman.SendEmail(email)
    If (success <> true) Then
        TextBox1.Text = TextBox1.Text & mailman.LastErrorText & vbCrLf
        TextBox1.Refresh()
        Exit While
    End If



Next

'  Remove the emails in bundle from the POP3 server.
success = mailman.DeleteBundle(bundle)
If (success <> true) Then
    TextBox1.Text = TextBox1.Text & mailman.LastErrorText & vbCrLf
    TextBox1.Refresh()
End If



 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser