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

 

 

 

 

 

 

EDIFACT - S/MIME Create, Sign, and Encrypt

Create an EDIFACT MIME message, signs it, and then encrypts.

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();

bool success;
success = mime.UnlockComponent("Anything for 30-day trial.");
if (success == false) {
    MessageBox.Show(mime.LastErrorText);
    return;
}

//  Assuming  you have an EDIFACT document loaded into
//  a string variable, set the MIME body with it:
string ediBody;
ediBody = "UNB+IATB:1+6XPPC+LHPPC+940101:0950+1' ...";
mime.SetBodyFromPlainText(ediBody);

//  The call to SetBodyFromPlainText automatically set the
//  content-type to "text/plain".
//  However, we want:  application/edifact;  name=om080923.edi
mime.ContentType = "application/edifact";
mime.Name = "om080923.edi";

//  We want the content-disposition to be:
//  Content-Disposition: attachment; filename="om080923.edi"
mime.Disposition = "attachment";
mime.Filename = "om080923.edi";

//  Content-Transfer-Encoding: quoted-printable
mime.Encoding = "quoted-printable";

//  Note: MIME header fields are case insensitive.

//  Add a few other header fields:
mime.AddHeaderField("Message-ID","<CHILKAT-MID-83cf2fbf-10cb-4322-ad79-4c1097fd56f2@Matt>");
mime.AddHeaderField("MIME-VERSION","1.0");

//  Display the complete non-signed, non-encrypted MIME:
textBox1.Text += mime.GetMime() + "\r\n";
textBox1.Text += "*********************************************" + "\r\n";

//  Sign the MIME using an opaque signature.
//  (but first load a certificate)
Chilkat.Cert cert = new Chilkat.Cert();
success = cert.LoadByCommonName("Chilkat Software, Inc.");
if (success == false) {
    MessageBox.Show(cert.LastErrorText);
    return;
}

success = mime.ConvertToSigned(cert);
if (success == false) {
    MessageBox.Show(mime.LastErrorText);
    return;
}

//  Perhaps the receiver is picky and wants the content-type to be "application/pkcs7-mime"
//  instead of "application/x-pkcs7-mime".  In that case, simply set the content-type:
mime.ContentType = "applicaton/pkcs7-mime";

//  Display the signed MIME:
textBox1.Text += mime.GetMime() + "\r\n";
textBox1.Text += "*********************************************" + "\r\n";

//  Now encrypt it.
Chilkat.Cert encryptCert = new Chilkat.Cert();
success = encryptCert.LoadByCommonName("speedi speedi");
if (success == false) {
    MessageBox.Show(encryptCert.LastErrorText);
    return;
}

success = mime.Encrypt(encryptCert);
if (success == false) {
    MessageBox.Show(mime.LastErrorText);
    return;
}

//  Again, if receiver is picky and wants the content-type to be "application/pkcs7-mime"
//  instead of "application/x-pkcs7-mime".  In that case, simply set the content-type:
mime.ContentType = "applicaton/pkcs7-mime";

//  Display the signed/encrypted MIME
textBox1.Text += mime.GetMime() + "\r\n";
textBox1.Text += "*********************************************" + "\r\n";

//  Save the MIME to a file:
success = mime.SaveMime("edifact_smime.txt");
if (success == false) {
    MessageBox.Show(mime.LastErrorText);
    return;
}

MessageBox.Show("Success!");
 

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

Email Component · XML Parser