C# Examples

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

C# Examples

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


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

Send MHTML Email from .mht File

Download: Chilkat .NET Assemblies

Answers this question: I have a MHTML file which is being created by a report. I wish to send it as an email. How do I do this?

        /*
         * Question: I have a MHTML file which is being created by a report. 
         * I wish to send it as an email. How do I do this?
         * 
         * MHTML stands for MIME HTML. It is a standard for including resources 
         * that in usual HTTP pages are linked externally, such as images and 
         * sound files, in the same file as the HTML code. The included data 
         * files are encoded using MIME. This format is sometimes referred to as 
         * MHT, after the suffix .mht given to such files by default when created 
         * by Microsoft Word, Internet Explorer or Opera. (Some people feel this 
         * is improper usage.)
         * 
         * The key to MHTML is that the content is encoded as if it were an email 
         * message, using the MIME type multipart/related. The first part is the 
         * HTML file, encoded normally. Subsequent parts are additional resources, 
         * identified by their original URLs.
         * 
         * 
         * */
        private void button15_Click(object sender, EventArgs e)
        {
            Chilkat.MailMan mailman = new Chilkat.MailMan();
            mailman.UnlockComponent("anything for 30-day trial");

            mailman.SmtpHost = "smtp.comcast.net";

            // If your SMTP server requires authentication, set your username/password:
            mailman.SmtpUsername = "***";
            mailman.SmtpPassword = "***";

            Chilkat.Email email = new Chilkat.Email();

            // A .mht file contains MIME, so it is identical to a .eml file 
            // in that it can be loaded by Email.LoadEml, but it is missing
            // the email headers such as "From", "To", "Subject", etc.
            // To send an MHT file as email, simply load it by calling LoadEml,
            // add header fields, attachments, etc, and send.
            bool success = email.LoadEml("myReport.mht");
            if (!success)
            {
                MessageBox.Show(mailman.LastErrorText);
                return;
            }

            // Set email headers and add an attachment
            email.From = "Matt <matt@chilkatsoft.com>";
            email.Subject = "Subject for MHT report";
            email.Body = "Body for MHTML report";
            email.AddTo("MHTML Email Support", "support@chilkatsoft.com");
            email.AddFileAttachment("something.pdf");

            // Send the MHTML e-mail...
            bool success = mailman.SendEmail(email);
            if (!success)
            {
                MessageBox.Show(mailman.LastErrorText);
            }
            else
            {
                MessageBox.Show("Mail Sent!");
            }

        }

Important: The download for this example does not contain the ChilkatDotNet.dll which
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/vbdotnet/step2.asp

 

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

Email Component · XML Parser