Framework EDI Reference. Methods and Properties
mailMessage. EnableMultipartSigned

Sets or gets the security configuration to indicate if multipart/signed should be applied when digital signing.

Syntax:

Remarks

The multipart/signed is applied only if digital signature is enabled.  This is the preferred method of signing with S/MIME, and if not enabled the Cryptographic Message Syntax (CMS) content type SignedData is used instead.  Default value is TRUE.

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

' Sign to "multipart/signed" message.
oMessage.EnableMultipartSigned = True

' Show message before encryption.
oMessage.Save App.Path & "\BeforeSigning.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.EnableAssurance = True
' Import the test certificate just created.
oSecurity.ImportCertificate App.Path & "\TestCertificate.cer"

' Apply signature
oMessage.Prepare

' Multipart/signed creates a message with exactly 2 bodies in the following order:
' 1. Protected Data. The content to be signed
' 2. Control information. The signature.
' To encode the control information only, get the 2nd message and modify by adding the content transfer encoding header
' with field value "base64".
Set oMessages = oMessage.GetMessages

' Encode in "base64" the control 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 & "\AfterSigning.TXT"

MsgBox "Done"

Samples