Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Send MHTML Email from .mht FileDownload: 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 |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.