Chilkat HOME Android™ ASP Visual Basic VB.NET C# iOS (IPhone) Objective-C C++ C Unicode C++ Unicode C MFC Delphi DLL Delphi ActiveX FoxPro Java Perl PHP Extension PHP ActiveX Python PowerShell Ruby SQL Server VBScript
|
EDIFACT - S/MIME Create, Sign, and EncryptCreate an EDIFACT MIME message, signs it, and then encrypts. LOCAL loMime LOCAL lnSuccess LOCAL lcEdiBody LOCAL loCert LOCAL loEncryptCert loMime = CreateObject('Chilkat.Mime') lnSuccess = loMime.UnlockComponent("Anything for 30-day trial.") IF (lnSuccess = 0) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF * Assuming you have an EDIFACT document loaded into * a string variable, set the MIME body with it: lcEdiBody = "UNB+IATB:1+6XPPC+LHPPC+940101:0950+1' ..." loMime.SetBodyFromPlainText(lcEdiBody) * The call to SetBodyFromPlainText automatically set the * content-type to "text/plain". * However, we want: application/edifact; name=om080923.edi loMime.ContentType = "application/edifact" loMime.Name = "om080923.edi" * We want the content-disposition to be: * Content-Disposition: attachment; filename="om080923.edi" loMime.Disposition = "attachment" loMime.Filename = "om080923.edi" * Content-Transfer-Encoding: quoted-printable loMime.Encoding = "quoted-printable" * Note: MIME header fields are case insensitive. * Add a few other header fields: loMime.AddHeaderField("Message-ID","<CHILKAT-MID-83cf2fbf-10cb-4322-ad79-4c1097fd56f2@Matt>") loMime.AddHeaderField("MIME-VERSION","1.0") * Display the complete non-signed, non-encrypted MIME: ? loMime.GetMime() ? "*********************************************" * Sign the MIME using an opaque signature. * (but first load a certificate) loCert = CreateObject('Chilkat.Cert') lnSuccess = loCert.LoadByCommonName("Chilkat Software, Inc.") IF (lnSuccess = 0) THEN =MESSAGEBOX(loCert.LastErrorText) QUIT ENDIF lnSuccess = loMime.ConvertToSigned(loCert) IF (lnSuccess = 0) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF * 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: loMime.ContentType = "applicaton/pkcs7-mime" * Display the signed MIME: ? loMime.GetMime() ? "*********************************************" * Now encrypt it. loEncryptCert = CreateObject('Chilkat.Cert') lnSuccess = loEncryptCert.LoadByCommonName("speedi speedi") IF (lnSuccess = 0) THEN =MESSAGEBOX(loEncryptCert.LastErrorText) QUIT ENDIF lnSuccess = loMime.Encrypt(loEncryptCert) IF (lnSuccess = 0) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF * 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: loMime.ContentType = "applicaton/pkcs7-mime" * Display the signed/encrypted MIME ? loMime.GetMime() ? "*********************************************" * Save the MIME to a file: lnSuccess = loMime.SaveMime("edifact_smime.txt") IF (lnSuccess = 0) THEN =MESSAGEBOX(loMime.LastErrorText) QUIT ENDIF =MESSAGEBOX("Success!") |
© 2000-2013 Chilkat Software, Inc. All Rights Reserved.