Framework EDI Reference. Methods and Properties
mailMessage. EnableMultipartEncrypt

Sets or gets the security configuration to indicate if multipart/encrypted should be applied when encrypting.

Syntax:

Remarks

The multipart/encrypted is applied only if encryption is enabled.  Default value is FALSE.

Example

Dim oEdiDoc As Fredi.ediDocument
Dim oSchemas As Fredi.ediSchemas
Dim oSchema As Fredi.ediSchema
Dim oMailDocument As Fredi.mailDocument
Dim oSecurity As Fredi.ediSecurity
Dim oSecurities As Fredi.ediSecurities
Dim oMessage As Fredi.mailMessage
Dim oTransferEncoding As Fredi.mailTransferEncoding
Dim oControlBody As Fredi.mailMessage
Dim oProtectedBody As Fredi.mailMessage
Dim oMessages As Fredi.mailMessages

' Create instance of Framework EDI.
Set oEdiDoc = New Fredi.ediDocument

' Disable standard reference library.
Set oSchemas = oEdiDoc.GetSchemas
oSchemas.EnableStandardReference = False

Set oSchema = oEdiDoc.LoadSchema(App.Path & "\ASCX12_850.SEF", Schema_Standard_Exchange_Format)

' Load EDI document normally.
oEdiDoc.LoadEdi App.Path & "\SampleEdi.X12"

' Get internet mail document object
Set oMailDocument = oEdiDoc.GetMailDocument

' Prepare the mail document with EDI data.
oMailDocument.PrepareEdi ediDocType_Subject

' Get the message.
Set oMessage = oMailDocument.GetMessage

' Encrypt in "multipart/encrypt" format.
oMessage.EnableMultipartEncrypt = True

' Show message before encryption.
oMessage.Save App.Path & "\BeforeEncrypt.TXT"

' Create a test certificate.
Set oSecurities = oEdiDoc.GetSecurities
oSecurities.CreateTestCertificate App.Path & "\TestCertificate.cer", "Joe Blow", "FrameworkEDI_Secure_Context_00", CspKeyType_KEYEXCHANGE

' Get the security object used to configure security for the message.
Set oSecurity = oMessage.GetSecurity

' Enable encryption.
oSecurity.EnableEncryption = True
' Import the test certificate just created.
oSecurity.ImportCertificate App.Path & "\TestCertificate.cer"

' Apply the encryption.
oMessage.Prepare

' Multipart/encrypt creates a message with exactly 2 bodies in the following order:
' 1. Control information. The encryption key.
' 2. Protected Data. The encrypted data.
' To encode, each message is modified by adding the content transfer encoding header
' with field value "base64".
Set oMessages = oMessage.GetMessages

' Encode in "base64" the control body.
Set oControlBody = oMessages.GetMessage(1)
Set oTransferEncoding = oControlBody.GetContentTransferEncoding
oTransferEncoding.MechanismName = "base64"

' Encode in "base64" the protected body.
Set oProtectedBody = oMessages.GetMessage(2)
Set oTransferEncoding = oProtectedBody.GetContentTransferEncoding
oTransferEncoding.MechanismName = "base64"

' Apply "base64" encoding.
oMessage.Prepare

' Show message after encryption.
oMessage.Save App.Path & "\AfterEncrypt.TXT"

MsgBox "Done"

Samples