Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Mail an HTML Web Page in C#
How to mail a Web Page in C# This is an example demonstrating how to create an email from a Web page and send it in C#. // Download a Web page including all associated images and style sheets,
// create a self-contained email, and send it.
private void MailWebPage_Click(object sender, System.EventArgs e)
{
// Chilkat MHT .NET is used to download and create the email.
Chilkat.Mht mht = new Chilkat.Mht();
mht.UnlockComponent("mhtUnlockCode");
// Chilkat Email .NET is used to send the email.
// It is a separate product and needs a separate unlock code.
Chilkat.MailMan mailman = new Chilkat.MailMan();
mailman.UnlockComponent("mailUnlockCode");
// Get the email.
Chilkat.Email email = mht.GetEmail("http://www.google.com");
// The Google page is utf-8, so let's convert the HTML in our
// email to iso-8859-1. We do this simply by setting the HtmlCharset
// property.
email.HtmlCharset = "iso-8859-1";
// Fill out the remainder of the email.
email.Subject = "This is the Google home page";
email.AddTo("Matt","matt@chilkatsoft.com");
email.From = "Chilkat Sales <sales@chilkatsoft.com>";
// You may or may not need an SMTP username/password.
mailman.SmtpHost = "smtp.earthlink.net";
//mailman.SmtpUsername = "myLogin";
//mailman.SmtpPassword = "myPassword";
bool success = mailman.SendEmail(email);
if (!success)
{
textBox1.Text = mailman.LastErrorXml;
}
else
{
textBox1.Text = "Mail Sent!";
}
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.