---
title: Utilities.clsMailMessage
summary: API reference for Utilities.clsMailMessage.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Core.Infragistics111
reference_type: package
---

# Utilities.clsMailMessage

`Utilities.clsMailMessage` is a stateless static service that bridges consuming applications to two otherwise-unrelated capabilities: streaming an already-created server file to the browser as a download, and dispatching outbound mail through the legacy SAIF mail SOAP web service. It resolves the mail service endpoint from configuration on every send call rather than caching it, and derives the download `Content-Type` purely from the file extension.

## Purpose
- Read a file from the web server's file system and stream it to the browser as an HTTP attachment download, selecting the `Content-Type` from the file extension. ([BR-CORE-027](../../business-rules.md#br-core-027-download-content-type-is-derived-from-the-file-extension-txt-textplain-csv-applicationvndms-excel))
- Dispatch outbound mail — optionally with an attachment supplied as a stream, byte array, or file path — through the legacy SAIF mail SOAP web service, whose URL is resolved from the `LegacyMailWebServiceUrl` configuration setting on every call. ([BR-CORE-024](../../business-rules.md#br-core-024-outbound-mail-is-sent-through-the-legacy-mail-web-service-whose-url-comes-from-the-legacymailwebserviceurl-configuration-setting))
- Publish standard mail boilerplate text (`STANDARD_DISCLAIMER`, `DO_NOT_REPLY`) so consuming applications include consistent disclaimer language.

## Context
- Namespace: `SAIF.Presentation.Web.Core.Utilities`
- Assembly/package: `SAIF.Presentation.Web.Core.Infragistics111` (merged into `SAIF.Presentation.Web.Infragistics111.dll` via `SAIF.BOF.Presentation.Web.Infragistics111.nuspec`)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `StreamDownloadFile(page, virtualFileName)` | `Public Shared Sub StreamDownloadFile(page As AppViewPageBase, virtualFileName As String)` | Maps the virtual path to a physical path, reads the file into a byte array, derives `Content-Type` from the extension (`.txt` → `text/plain`, `.csv` → `application/vnd.ms-excel`, other → empty*), writes the `content-disposition`/`Content-Length` headers, `BinaryWrite`s the bytes, and ends the response. |
| `SendMail(to, from, subject, body)` | `Public Shared Function SendMail(to As String, from As String, subject As String, body As String) As Boolean` | Creates a `SAIFMail.clsSAIFMessage` SOAP client, sets its `Url` from `LegacyMailWebServiceUrl`, and invokes the remote `SendMail` operation with no attachment. Always returns `False` because the function body contains no `Return` statement.* |
| `SendMail(to, from, subject, body, attachmentBytes, attachmentName)` | `Public Shared Function SendMail(to As String, from As String, subject As String, body As String, attachmentBytes As Byte(), attachmentName As String) As Boolean` | Same dispatch flow as the base overload, with an attachment supplied directly as a byte array. Always returns `False` for the same reason.* |
| `SendMailWithAttachment(to, from, subject, body, filePath)` | `Public Shared Function SendMailWithAttachment(to As String, from As String, subject As String, body As String, filePath As String) As Boolean` | Materializes the file at `filePath` via `GetFileAsBytes`, then dispatches through the same SOAP client flow as `SendMail`. Always returns `False` for the same reason.* |
| `SendMailWithAttachment(to, from, subject, body, attachmentStream, attachmentName)` | `Public Shared Function SendMailWithAttachment(to As String, from As String, subject As String, body As String, attachmentStream As Stream, attachmentName As String) As Boolean` | Materializes the stream via `GetStreamAsBytes`, then dispatches through the same SOAP client flow. Always returns `False` for the same reason.* |
| `GetFileAsBytes(filePath)` | `Public Shared Function GetFileAsBytes(filePath As String) As Byte()` | Reads the file at the given physical path into a byte array for use as a mail attachment. |
| `GetStreamAsBytes(stream)` | `Public Shared Function GetStreamAsBytes(stream As Stream) As Byte()` | Reads the given stream fully into a byte array for use as a mail attachment. |
| `STANDARD_DISCLAIMER` | `Public Const STANDARD_DISCLAIMER As String` | Standard legal/confidentiality disclaimer boilerplate text consuming applications append to outbound mail. |
| `DO_NOT_REPLY` | `Public Const DO_NOT_REPLY As String` | Standard "do not reply" boilerplate text consuming applications append to outbound automated mail. |

## Behavioral notes
- `LegacyMailWebServiceUrl` is resolved on every `SendMail`/`SendMailWithAttachment` call rather than cached, making mail delivery sensitive to environment-service availability at send time.*
- All `SendMail`/`SendMailWithAttachment` overloads are declared `As Boolean` but always return `False`, regardless of whether the mail was actually dispatched, because none of the method bodies contain a `Return` statement.*
- File extensions other than `.txt` or `.csv` receive an empty `Content-Type` in `StreamDownloadFile`, which browsers may handle inconsistently.*

## Constraints and usage notes
- Callers must not rely on the `Boolean` return value of any `SendMail`/`SendMailWithAttachment` overload to detect success — it is always `False`.
- No existence check is documented before `StreamDownloadFile`'s file read; a missing file surfaces as a runtime I/O exception.**

> **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.Presentation.Web.Core.Infragistics111/clsMailMessage.vb`
