Framework EDI Reference. Methods and Properties
mailDocument. PrepareEdi

Prepares the subject message with EDI data.

Syntax:

Parameters:

Returns

Returns 1 if the operation is successful; otherwise the operation returns zero.

Remarks

PrepareEdi generates a message formatted in internet mail consisting of message headers and the message body using the data of the EDI document already loaded, or created.  Existing data in the subject message is erased and replaced with new message content, which consists of:

  1. MIME version header with value of “1.0”.
  2. Content-Type header with value of “Application/EDI-X12” for ASC/X12 document or “Application/EDIFACT” for UN/EDIFACT document.
  3. Content-Transfer-Encoding header with value "binary".
  4. EDI document output is stored in the body of the message.

 Example:

 

If security has been enabled it is applied after the message has been generated, and once applied the security settings are disabled.  This is so that when preparing the document again, redundantly securing the document is prevented and one must re-enable the security to secure the document again.

Example

Dim oEdiDoc As Fredi.ediDocument
Dim oSchemas As Fredi.ediSchemas
Dim oSchema As Fredi.ediSchema
Dim oMailDocument As Fredi.mailDocument

' 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

' Load the mail document containing the EDI data.
oMailDocument.PrepareEdi ediDocType_Subject

oMailDocument.Save App.Path & "\Output.TXT"

MsgBox "Done"

Samples