Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

EDIFACT - S/MIME Create, Sign, and Encrypt

Download Chilkat MIME ActiveX

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

Dim mime As New ChilkatMime

Dim success As Long
success = mime.UnlockComponent("Anything for 30-day trial.")
If (success = 0) Then
    MsgBox mime.LastErrorText
    Exit Sub
End If

'  Assuming  you have an EDIFACT document loaded into
'  a string variable, set the MIME body with it:
Dim ediBody As String
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:
Text1.Text = Text1.Text & mime.GetMime() & vbCrLf
Text1.Text = Text1.Text & "*********************************************" & vbCrLf

'  Sign the MIME using an opaque signature.
'  (but first load a certificate)
Dim cert As New ChilkatCert
success = cert.LoadByCommonName("Chilkat Software, Inc.")
If (success = 0) Then
    MsgBox cert.LastErrorText
    Exit Sub
End If

success = mime.ConvertToSigned(cert)
If (success = 0) Then
    MsgBox mime.LastErrorText
    Exit Sub
End If

'  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:
Text1.Text = Text1.Text & mime.GetMime() & vbCrLf
Text1.Text = Text1.Text & "*********************************************" & vbCrLf

'  Now encrypt it.
Dim encryptCert As New ChilkatCert
success = encryptCert.LoadByCommonName("speedi speedi")
If (success = 0) Then
    MsgBox encryptCert.LastErrorText
    Exit Sub
End If

success = mime.Encrypt(encryptCert)
If (success = 0) Then
    MsgBox mime.LastErrorText
    Exit Sub
End If

'  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
Text1.Text = Text1.Text & mime.GetMime() & vbCrLf
Text1.Text = Text1.Text & "*********************************************" & vbCrLf

'  Save the MIME to a file:
success = mime.SaveMime("edifact_smime.txt")
If (success = 0) Then
    MsgBox mime.LastErrorText
    Exit Sub
End If

MsgBox "Success!"

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