Module · Regira.Office.Mail

Mail in .NET.
Send it, and parse what arrives.

Two jobs that usually pull in two unrelated libraries: sending transactional mail with attachments, and reading the .msg and .eml files people forward you. Both live here, behind their own interfaces.

← All Office modules

§ 01The contract

What every provider gives you.

The interfaces below are the part that does not change when you swap the library underneath. Each provider then adds whatever extras its own library exposes.

01

Send

A message object with sender, recipients, CC and BCC, an HTML or plain body, and attachments as file objects. The response says whether it went.

02

Providers

SendGrid and Mailgun each register with their own config; a DummyMailer takes their place in tests and local runs.

03

Parse

IMessageParser reads Outlook MSG and EML into the same message shape, attachments included — useful for inboxes that feed a workflow.

04

Identity

The mail service plugs into ASP.NET Identity as its IEmailSender, so confirmation and reset mail goes the same way as everything else.

Interfaces
IMailServiceIMessageParserMessageObjectIMailResponse
§ 02Providers

3 published implementations.

Install the one that fits your runtime and licensing, and name it once at registration. Every package here is published on nuget.org.

MailgunMsgReaderSendGrid
§ 03In code

Inject the interface. Name the provider once.

The provider appears where the concrete class is constructed, and nowhere else. Always-current samples live in the package documentation.

Send a message with an attachmentC#
// Register a provider once; inject IMailService everywhere else.
services.AddSendGrid(cfg => cfg.Key = configuration["Mail:SendGrid:Key"]!);

var message = new MessageObject
{
    From    = new MailAddress { Email = "orders@example.com", DisplayName = "Example" },
    Subject = $"Order confirmation #{order.Number}",
    Body    = html,
    IsHtml  = true,
    To      = [new MailRecipient { Email = order.CustomerEmail }],
    Attachments =
    [
        new BinaryFileItem { FileName = "invoice.pdf", Bytes = invoicePdf.GetBytes() }
    ]
};

IMailResponse result = await mailer.Send(message);
§ 04Without .NET

The same thing, over HTTP.

Parse Outlook MSG and EML files over HTTP, returning message content and optionally extracting attachments as a zip archive.

Call it from any language.

The free tier needs no key and is rate-limited to 5 requests / 60 s. A trial or commercial key removes the limit — send it in the X-License-Key header.

Also explore

Word

Fill a .docx template with values and repeating tables, merge documents and convert to PDF — over Spire or MiniWord.