Search Results write_mime_header




Overview

OKS_MAIL is a PL/SQL package body owned by APPS that provides a general-purpose outbound email facility for Oracle E-Business Suite service and support modules. It encapsulates the construction and transmission of MIME-formatted messages over SMTP, allowing other EBS components to send plain text messages, HTML bodies, and file attachments without directly programming against the UTL_SMTP and DBMS_LOB interfaces. The package is classified as OTHER within the ETRM 12.1.1 / 12.2.2 metadata, and its header comment (OKSMAILB.pls 120.0, dated 2005/05/25) indicates it has been a stable utility since the earlier 11i releases. Although it belongs to the Service (OKS) product family, it is a generic mail transport layer with no dependency on service-specific tables; it is referenced by zero other documented packages in the ETRM repository, meaning callers invoke it directly rather than through an intermediate wrapper.

Key Procedures and Functions

The package exposes 24 documented procedures and functions. The user's search term end_mail refers to the END_MAIL procedure, which terminates an SMTP dialogue previously opened by BEGIN_MAIL or BEGIN_MAIL_IN_SESSION; it emits any outstanding MIME boundary, issues the SMTP QUIT command through UTL_SMTP, and closes the connection. Its counterpart BEGIN_MAIL establishes the SMTP connection, performs the EHLO/HELO handshake, and writes the envelope and header block for a single message. BEGIN_MAIL_IN_SESSION and END_MAIL_IN_SESSION perform the equivalent operations while keeping a session open across multiple messages, and BEGIN_SESSION / END_SESSION manage the underlying connection lifecycle itself.

MAIL is the high-level convenience wrapper that sequences BEGIN_MAIL, WRITE_TEXT, and END_MAIL in a single call. WRITE_TEXT, WRITE_MB_TEXT, and WRITE_RAW write message bodies as text, multibyte text, or unencoded binary data respectively. ATTACH_TEXT and ATTACH_BASE64 transmit attachment content using either plain text or Base64 encoding. BEGIN_ATTACHMENT and END_ATTACHMENT delimit a MIME part, while WRITE_BOUNDARY emits the multipart separators (the internal FIRST_BOUNDARY and LAST_BOUNDARY constants) that chain parts together. WRITE_MIME_HEADER writes individual header lines such as Content-Type or Content-Transfer-Encoding. Three higher-level attachment routines — SEND_ATTACHMENT, SEND_TEXT_ATTACHMENT, and SEND_BINARY_ATTACHMENT — combine the header, boundary, and encoding steps into single calls. GET_ADDRESS is a standalone helper that parses a mailbox string in any of the three accepted formats (bare address, quoted display name, or display name plus angle-bracketed address) and returns only the routable email address.

Tables Accessed

The package performs no DML against application tables. Its documented dependencies are all supplied PL/SQL and Oracle-supplied packages referenced through APPS synonyms: UTL_SMTP for the SMTP conversation, DBMS_LOB for reading attachment LOB locators, UTL_RAW for binary-to-raw conversion, UTL_TCP for lower-level transport support, UTL_HTTP where content must be retrieved from a URL, and PLITBLM, the internal package that backs associative array (index-by table) handling used by the recipient_rec_tbl collection type passed to BEGIN_MAIL and MAIL. The absence of any Service schema table reference confirms the package is a pure transport utility; all message content is supplied by the caller.

Usage Notes

OKS_MAIL is invoked from concurrent programs and PL/SQL-based workflows that must deliver notifications, order confirmations, or report output as email attachments. The typical pattern is either a single MAIL call for short text notifications or an explicit BEGIN_MAIL / BEGIN_ATTACHMENT / ATTACH_BASE64 / END_ATTACHMENT / END_MAIL sequence when binary files must be attached. Direct form invocation is uncommon because forms generally delegate to the notification framework; customizations and extensions written against the OKS schema are the most frequent callers. Because the package relies on UTL_SMTP, the SMTP host and port must be configured in the database initialization parameters and the APPS schema must hold execute privileges on the supplied packages. Error handling throughout is defensive: each routine traps WHEN OTHERS and writes SQLERRM to the concurrent program log via FND_FILE.PUT_LINE, so failures surface in the request log rather than raising an exception to the caller. Note that APPS.OKS_MAIL is distinct from FND_SMTP and the workflow mailer; it is a lower-level utility and does not consult the notification preferences or mailer configuration tables maintained by those components.