C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP 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 HTML Email with Embedded Image

Download: Chilkat .NET Assemblies

C# source code sample showing how to send an HTML email with images embedded within the HTML.

bool success = false;

// Create a mailman object for sending email.
Chilkat.MailMan mailman = new Chilkat.MailMan();

// Any string argument automatically begins the 30-day trial.
mailman.UnlockComponent("30-day trial");

// Set the SMTP server.
mailman.SmtpHost = "smtp.earthlink.net";

// Create an email object
Chilkat.Email email = new Chilkat.Email();

// Add an embedded image to the HTML email.
string cid = email.AddRelatedFile("dude.gif");
if (cid == null)
{
	MessageBox.Show(email.LastErrorText);
	return;
}

// Update the HTML to reference the image using the CID
string htmlBody = "<html><body>Embedded Image:<br><img src=\"cid:IMAGE_CID\"></body></html>";
htmlBody = htmlBody.Replace("IMAGE_CID",cid);

// Set the basic email stuff: HTML body, subject, "from", "to"
email.SetHtmlBody(htmlBody);
email.Subject = "This is an HTML email with an embedded image.";
email.AddTo("Chilkat Support","support@chilkatsoft.com");
email.From = "Programmer <programmer@chilkatsoft.com>";

success = mailman.SendEmail(email);
if (!success)
{
	MessageBox.Show(mailman.LastErrorText);
	return;
}

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-2013 Chilkat Software, Inc. All Rights Reserved.