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

 

 

 

 

 

 

Load MIME (or S/MIME) and Send as Email

Demonstrates how to load a MIME file and send it 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

Chilkat.Mime mime = new Chilkat.Mime();
Chilkat.MailMan mailman = new Chilkat.MailMan();

//  Any string argument automatically begins the 30-day trial.
bool success;
success = mime.UnlockComponent("30-day trial");
if (success != true) {
    MessageBox.Show(mime.LastErrorText);
    return;
}

//  Any string argument automatically begins the 30-day trial.
success = mailman.UnlockComponent("30-day trial");
if (success != true) {
    MessageBox.Show(mailman.LastErrorText);
    return;
}

//  Set the SMTP server.
mailman.SmtpHost = "smtp.chilkatsoft.com";

//  Set the SMTP login/password (if required)
mailman.SmtpUsername = "myUsername";
mailman.SmtpPassword = "myPassword";

//  Load the MIME (or S/MIME) from a file:
success = mime.LoadMimeFile("edifact_smime.txt");
if (success != true) {
    MessageBox.Show(mime.LastErrorText);
    return;
}

string fromAddr;
string recipient;
fromAddr = "admin@chilkatsoft.com";
recipient = "support@chilkatsoft.com";

//  Add email header fields to the MIME:
mime.AddHeaderField("From",fromAddr);
mime.AddHeaderField("To",recipient);
mime.AddHeaderField("Subject","Here is my EDIFACT signed and encrypted...");

//  We want a Date header with the current date/time.  The email object
//  automatically generates it.  Therefore we'll create an email object and then
//  copy the Date header:
Chilkat.Email email = new Chilkat.Email();
string dateStr;
dateStr = email.GetHeaderField("Date");
mime.AddHeaderField("Date",dateStr);

//  It is not necessary to save the MIME to a file.
//  We're doing it here just to have a look at the .eml in a text editor...
success = mime.SaveMime("email.eml");
if (success != true) {
    MessageBox.Show(mime.LastErrorText);
    return;
}

//  Now send the MIME via SMTP:
string mimeContent;
mimeContent = mime.GetMime();
success = mailman.SendMime(fromAddr,recipient,mimeContent);
if (success != true) {
    MessageBox.Show(mailman.LastErrorText);
    return;
}

success = mailman.CloseSmtpConnection();
if (success != true) {
    MessageBox.Show("Connection to SMTP server not closed cleanly.");
}

MessageBox.Show("Mail Sent!");
 

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

Email Component · XML Parser