Log exception and send notification email¶
This operation layers a second side effect — an outbound HTML email — on top of the standard error-logging path. It reuses the same context-capture, ViewState-suppression, and persistence logic as CreateError(...), then composes a notification email whose sender address is always derived from the captured username rather than any caller-supplied value.
| Field | Value |
|---|---|
| Operation ID | LOG-OP-003 |
| Trigger | Caller invokes clsLogError.CreateErrorWithEmail(...). |
| Inputs | Recipient address, Exception, and optional state objects. |
| Outputs | Boolean; False only when ViewState suppression matches, otherwise True even if either the log write or the email send fails. |
| Primary components | clsLogError.CreateErrorWithEmail, clsLogError.WriteMessage, SAIFMail.clsSAIFMessage.SendMail |
| Entry point | SAIF.Framework.Logging/clsLogError.vb |
Steps¶
- Reuse the same payload-construction path as
CreateError(...): createclsLogError, capture machine, application, page, environment, and user context, flatten any nested exceptions, and serialize whatever state objects the caller supplied (BR-005).
Origin: The current-user resolution inside step 1 delegates to
clsSecurityPrincipal, documented in Principal identity initialization (SAIF.Framework.Security). 2. RunSuppressLogging()and returnFalseimmediately when the formatted exception text matches either ViewState suppression signature — no email is composed for a suppressed error (BR-004). 3. Persist the error throughWriteMessage()before attempting the email. - If no file sink is active, resolveloggingServiceUrl, map the payload intowsLogging.ErrorInfoStruct, callWriteError(...), dispose the proxy, and swallow any resulting exception (BR-005). - Otherwise appendErrorInfoStruct.ToCSVString()to the open file writer and flush it.Origin: The
loggingServiceUrllookup in step 3 delegates to Environment API configuration retrieval, summarized in Retrieve a configuration setting (SAIF.Framework.Security.EnvironmentApi). 4. Build and dispatch the notification email. - InstantiateNew SAIF.Framework.Mail.SAIFMail.clsSAIFMessage. - ResolvelegacyMailServiceUrl, append?op=SendMail, and assign the resulting URL to the proxy before invoking the mail operation. - Format the subject withMSGSUBJECT, substituting the captured application name, machine name, and environment. - CallSendMail(inSendTo, ErrorInfo.Username & "@SAIF.COM", subject, ErrorInfo.ToHTMLString()), so the sender address always resolves to the@SAIF.COMdomain regardless of the recipient (BR-006).Origin: The endpoint lookup in step 4.2 delegates to Environment API configuration retrieval, and the synchronous SOAP invocation in step 4.4 follows the mail-send flow summarized in Send email with body (
SAIF.Framework.Mail). 5. Swallow any exception raised anywhere in the combined log-write or email-send flow, then returnTrue, so a notification-delivery problem never breaks the caller's original work (BR-005).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([CreateErrorWithEmail request]) --> Build[Build ErrorInfoStruct]
Build --> Suppress{ViewState signature found?}
Suppress -->|Yes| EndDrop([Return False])
Suppress -->|No| Persist[Write error through active sink]
Persist --> Mail[Resolve legacyMailServiceUrl and send HTML email]
Mail --> EndOk([Return True])
Failure and edge-case behavior¶
- ViewState-noise exceptions are discarded before either the sink write or the email attempt starts, so no notification email is ever sent for suppressed errors (BR-004).
- The sender address is always
Username + "@SAIF.COM", even for users whose real address lives in a different domain (BR-006). - The method still returns
Truewhen the mail endpoint is unreachable, because the outer catch absorbs notification failures along with logging failures (BR-005).
Related documentation¶
Sources¶
SAIF.Framework.Logging/clsLogError.vbSAIF.Framework.Logging/ErrorInfoStruct.vbSAIF.Framework.Logging/clsLogCommon.vbSAIF.Framework.Security/clsSecurityPrincipal.vbSAIF.Framework.Security.EnvironmentApi/Services.Common/EnvironmentServiceBase.csSAIF.Framework.Security.EnvironmentApi/Services.Common/EnvironmentConfigKeys.csSAIF.Framework.Mail/Web References/SAIFMail/Reference.vb