• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Build MIME

Builds a MIME message programmatically and writes it to a file.

Code

using DRIT.Mail.Rfc.Mime;

var message = new MimeMessage
{
    Subject = "Hello from DRIT.Mail",
};

message.From.Add(new MailboxAddress("sender@example.com", "Sender"));
message.To.Add(new MailboxAddress("recipient@example.com", "Recipient"));

var textPart = new TextPart("plain")
{
    Text = "This is the plain text body of the message.",
};
message.Body = textPart;

// Write the message to a file
message.Write("output.eml");

Remarks

MimeMessageBuilder offers a fluent API for constructing more complex messages, including multipart/alternative and multipart/mixed structures with attachments.

  • Improve this Doc
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX