---
title: Mail
summary: API reference for Mail.
status: draft
owner: <owner>
last_reviewed: 2026-07-23
library: SAIF.Framework.Mail
reference_type: package
---

# Mail

`Mail` is a `Public Module` — the sole public-facing component of `SAIF.Framework.Mail`. It provides a simplified static API for sending email through the legacy `clsSAIFMessage.asmx` SOAP mail service, with overloads for subject-only, subject+body, HTML/plain-text, and attachment (stream, file path, byte array) variants. All members are shared module-level functions/constants; the module holds no state between calls.

## Purpose
- Provide a single, simplified entry point for sending email without requiring callers to interact with the generated `SAIFMail.clsSAIFMessage` SOAP proxy directly.

## Context
- Namespace: `SAIF.Framework.Mail`
- Assembly/package: `SAIF.BOF.Framework.Mail`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `STANDARD_DISCLAIMER` | `Public Const STANDARD_DISCLAIMER As String` | Standard email disclaimer/confidentiality notice text for callers to append to message bodies. |
| `DO_NOT_REPLY` | `Public Const DO_NOT_REPLY As String` | Auto-reply notice text indicating the message was auto-generated and should not be replied to. |
| `SendMail` | `Function SendMail(inToAddress As String, inFromAddress As String, inSubject As String, Optional isHtml As Boolean = True) As Boolean` | Sends a subject-only message (empty body); HTML by default per [BR-002](../../business-rules.md#br-002-html-body-is-the-default-format). |
| `SendMail` | `Function SendMail(inToAddress As String, inFromAddress As String, inSubject As String, inMessage As String, Optional isHtml As Boolean = True) As Boolean` | Sends a message with a subject and a body; HTML by default per [BR-002](../../business-rules.md#br-002-html-body-is-the-default-format). |
| `SendMailWithOptions` | `Function SendMailWithOptions(inToAddress As String, inFromAddress As String, inSubject As String, isHtml As Boolean, Optional attachments As SAIFMail.clsAttachment() = Nothing, Optional linkedResources As SAIFMail.clsLinkedResource() = Nothing) As Boolean` | Sends a message with optional attachments/linked resources and no body; delegates to the body overload with `String.Empty`. |
| `SendMailWithOptions` | `Function SendMailWithOptions(inToAddress As String, inFromAddress As String, inSubject As String, inMessage As String, isHtml As Boolean, Optional attachments As SAIFMail.clsAttachment() = Nothing, Optional linkedResources As SAIFMail.clsLinkedResource() = Nothing) As Boolean` | Sends a full-featured message with a body plus optional attachments/linked resources via the proxy's `SendEmail` SOAP operation. |
| `SendMailWithAttachment` | `Function SendMailWithAttachment(inToAddress As String, inFromAddress As String, inSubject As String, inStream As Stream, inAttachName As String) As Boolean` | Sends a message with a subject and a stream attachment, no body; converts the stream via `GetStreamAsBytes` before calling `SendWithAttach`. |
| `SendMailWithAttachment` | `Function SendMailWithAttachment(inToAddress As String, inFromAddress As String, inSubject As String, inMessage As String, inStream As Stream, inAttachName As String) As Boolean` | Sends a message with a subject, body, and a stream attachment; converts the stream via `GetStreamAsBytes` before calling `SendWithAttach`. |
| `SendMailWithAttachment` | `Function SendMailWithAttachment(inToAddress As String, inFromAddress As String, inSubject As String, inMessage As String, inFilePath As String, inAttachName As String) As Boolean` | Sends a message with a subject, body, and a file-path attachment; reads the file via `GetFileAsBytes` before calling `SendWithAttach`. |
| `SendMailWithAttachment` | `Function SendMailWithAttachment(inToAddress As String, inFromAddress As String, inSubject As String, inMessage As String, inAttachment() As Byte, inAttachName As String) As Boolean` | Sends a message with a subject, body, and an already-materialized byte-array attachment directly via `SendWithAttach`. |
| `GetFileAsBytes` | `Function GetFileAsBytes(inPath As String) As Byte()` | Internal utility: reads a file at `inPath` into a byte array via a `FileStream`; always closes the stream in `Finally`, but re-throws the original exception via `Throw ex` per [BR-004](../../business-rules.md#br-004-file-handles-are-always-released-but-the-original-exceptions-stack-trace-is-reset). |
| `GetStreamAsBytes` | `Function GetStreamAsBytes(inStream As Stream) As Byte()` | Internal utility: reads an already-open stream into a byte array; returns `Nothing` for a `Nothing` input per [BR-005](../../business-rules.md#br-005-a-nothing-stream-input-yields-a-nothing-byte-array-instead-of-an-exception). |

## Behavioral notes
- Every `Send*` function follows the same fixed sequence: instantiate `SAIFMail.clsSAIFMessage` → resolve `.Url` from `AppGlobal.EnvironmentService.GetConfigSetting("legacyMailServiceUrl")` per [BR-001](../../business-rules.md#br-001-mail-is-always-routed-through-the-configured-legacy-mail-service-url) → invoke one SOAP operation (`SendMail`, `SendMailAsText`, `SendWithAttach`, or `SendEmail`) → dispose the proxy → return `True`.
- All `Send*` functions return `True` regardless of the SOAP call's actual outcome, per [BR-003](../../business-rules.md#br-003-send-operations-always-report-success-regardless-of-actual-outcome); no exception handling or success/failure branching surrounds the SOAP invocation itself.*
- The module holds no state between calls — each function creates and disposes its own `SAIFMail.clsSAIFMessage` proxy instance rather than sharing a client.*

## Constraints and usage notes
- Callers cannot rely on the `Boolean` return value to confirm actual delivery success; only an unhandled exception from the underlying SOAP call would signal failure.*
- The `legacyMailServiceUrl` environment configuration setting must be resolvable at runtime, or the SOAP proxy falls back to the design-time default URL baked into `app.config`/`My.Settings`.
- Attachment overloads accepting a `Stream` or file path convert their input to a byte array before the SOAP call; very large files/streams are read entirely into memory.*

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Framework.Mail\MailServices.vb
