Framework EDI Reference. Methods and Properties
mailMessage. GetSecurity

Gets the security object of the message.

Syntax:

Returns

If successful, an object of FREDI.ediSecurity is returned; otherwise an empty result is returned.

Remarks

The security object controls how the message is to be secured or unsecured.

 

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

' 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

' 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

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

MsgBox "Done"

Samples