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

 

 

 

 

 

 

Load MHT and Send as 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

Load a .MHT file and send it as email.

'  The mailman object is used for sending and receiving 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 SMTP server.
mailman.SmtpHost = "smtp.comcast.net"

'  Create a new email object
Dim email As New Chilkat.Email()

'  MHT is MIME and therefore can be loaded directly
'  into an email object via the email.LoadEml method.
'  However, if the HTML sub-part of the MIME contains
'  header fields such as this:

'  Content-ID: <BalanceSheet>
'  Content-Disposition: inline;
'  	filename="BalanceSheet"
'  Content-Type: text/html;
'  	name="BalanceSheet";
'  	charset="utf-8"

'  Microsoft Outlook will interpret this as an attached HTML file
'  rather than the HTML body of the email.  Interestingly,
'  Mozilla Thunderbird handles it correctly, but Outlook does not.
'  Google's GMail also handles it correctly.  Yahoo Mail doesn't
'  know what to do and displays nothing -- not even the "attachment".

'  Rather than loading the MHT into the email object, we'll
'  first load it into a Chilkat MIME object and check for
'  these headers.  We want the header fields of the HTML sub-part
'  to look like this:

'  Content-Type: text/html;
'  	charset="utf-8"

'  To do so, we'll remove the Content-ID and Content-Disposition
'  header fields, and the "name" attribute from the
'  Content-Type header.

'  Note: Chilkat MIME is a separate product.  This code
'  would require licenses to both Chilkat Email and Chilkat Mime,
'  or alternatively a Chilkat Bundle license (which includes
'  all Chilkat components).

Dim mime As New Chilkat.Mime()

success = mime.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
    MsgBox("Failed to unlock MIME component")
    Exit Sub
End If


success = mime.LoadMimeFile("test.mht")
If (success <> true) Then
    MsgBox(mime.LastErrorText)
    Exit Sub
End If


'  Is this a multipart/related?  If so, find the HTML part,
'  which should be the 1st sub-part.
If (mime.IsMultipartRelated() = true) Then
    '  Find the HTML part.
    Dim mimePart As Chilkat.Mime
    Dim n As Long
    Dim i As Long
    n = mime.NumParts

    For i = 0 To n - 1
        mimePart = mime.GetPart(i)
        If (mimePart.IsHtml() = true) Then
            Exit For
        End If


    Next
    If (Not (mimePart Is Nothing )) Then
        '  Remove these header fields:
        mimePart.SetHeaderField("Content-Disposition","")
        mimePart.SetHeaderField("Content-ID","")
        '  Remove the "name" attribute from the Content-Type header:
        mimePart.Name = ""

    End If

End If


email.SetFromMimeText(mime.GetMime())

email.Subject = "This is a test"

email.From = "Chilkat Support <support@chilkatsoft.com>"
email.AddTo("Chilkat Admin","admin@chilkatsoft.com")

success = mailman.SendEmail(email)
If (success <> true) Then
    MsgBox(mailman.LastErrorText)
Else
    MsgBox("Mail Sent!")
End If

 

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

Mail Component · XML Parser