Table of Contents

Struct MailAddress

Namespace
Vonage.Common
Assembly
Vonage.dll

Represents a validated email address using RFC 5321 standards.

public readonly struct MailAddress
Inherited Members

Remarks

Uses MailAddress internally for validation.

Use Parse(string) to create an instance with validation.

Properties

Address

Gets the validated email address string.

public string Address { get; }

Property Value

string

Methods

Parse(string)

Parses and validates an email address.

public static Result<MailAddress> Parse(string email)

Parameters

email string

The email address to validate.

Returns

Result<MailAddress>

A Result<T> containing the validated MailAddress on success, or an IResultFailure if the email format is invalid.

Examples

var result = MailAddress.Parse("user@example.com");
result.Match(
    email => Console.WriteLine($"Valid email: {email.Address}"),
    failure => Console.WriteLine("Invalid email format")
);