Aspose.Email FOSS for .NET은 MIT 라이선스를 가진 종속성이 없는 C# 라이브러리로, Microsoft Outlook .msg 파일, Compound File Binary (CFB) 컨테이너 및 EML 메시지를 처리합니다. 단일 NuGet 패키지를 추가하면 Microsoft Outlook이나 어떤 독점 런타임도 설치하지 않고 즉시 이메일 메시지를 읽고, 생성하고, 처리할 수 있습니다.
이 라이브러리는 두 가지 수준의 접근 방식을 제공합니다. 낮은 수준에서는 CfbReader와 CfbWriter가 CFB 바이너리 컨테이너에 대한 완전한 제어를 제공하며, 디렉터리 항목을 탐색하고, 스토리지 노드와 스트림 데이터를 읽고 쓰며, 원시 섹터 레이아웃을 검사합니다. MsgReader와 MsgWriter는 CFB 위에 있는 MSG 형식을 처리하여 MAPI 속성 스트림, 수신자 테이블 및 첨부 파일 하위 스토리지를 노출합니다. 높은 수준에서는 MapiMessage를 사용하여 처음부터 새 메시지를 만들고, 제목, 본문, 발신자 및 수신자를 읽으며, 첨부 파일을 관리하고, 내장된 MIME 구현을 통해 MSG와 EML 형식 간을 변환할 수 있습니다.
이 라이브러리는 .NET 8.0 이상을 대상으로 하며 네이티브 종속성이 없어 Windows, Linux, macOS, Docker 컨테이너 및 서버리스 함수에 적합합니다.
CfbReader.FromFile(), CfbReader.FromStream(), or new CfbReader(data).IterStorages(), IterStreams(), IterChildren(), and IterTree().ResolvePath(names) to locate a specific stream by name chain.CfbDocument and serialize to bytes or file via CfbWriter.ToBytes() or CfbWriter.WriteFile().CfbStorage and CfbStream nodes to any storage node before serialization..msg files — direct CFB access enables forensic inspection and repair.MsgReader.FromFile() or MsgReader.FromStream() and access the underlying MAPI property streams, recipient records, and attachment sub-storages.MsgDocument with MsgWriter.ToBytes() or MsgWriter.WriteFile().MsgStorage, MsgStream, and MsgReader.ParseTopLevelPropertyStream().MsgStorage.FindStream() and MsgStorage.FindStorage() to locate named sub-entries..msg files from archive directories and extract metadata or attachments..msg files programmatically and deliver them to Outlook-based mail systems.MapiMessage.Create(subject, body), set SenderName, SenderEmailAddress, and HtmlBody.To, Cc, and Bcc recipients via AddRecipient() with email address and display name.AddAttachment() or construct MapiAttachment objects directly with Filename, MimeType, ContentId, and Data.message.Save() or message.Save(stream) and reload with MapiMessage.FromFile() or MapiMessage.FromStream().message.Attachments, and save each attachment.Data to disk.message.Subject, message.Body, message.SenderEmailAddress, and message.Recipients without COM automation..eml file (RFC 5322 / MIME) into a full MapiMessage object via MapiMessage.LoadFromEml(stream).MapiMessage back to MIME format with message.SaveToEml() or message.SaveToEml(stream)..eml and .msg files to a single format..eml fixtures in tests and verify they survive MSG round-trip without data loss.Open an Outlook MSG file from a stream and print the subject — no Microsoft Outlook required.
using System.IO;
using Aspose.Email.Foss.Msg;
using var stream = File.OpenRead("sample.msg");
var message = MapiMessage.FromStream(stream);
Console.WriteLine(message.Subject);
Build a complete email with sender, recipient, and attachment, then write it to an MSG file.
using System.IO;
using Aspose.Email.Foss.Msg;
var message = MapiMessage.Create("Hello", "Body");
message.SenderName = "Alice";
message.SenderEmailAddress = "alice@example.com";
message.AddRecipient("bob@example.com", "Bob");
using var attachmentStream = new MemoryStream("abc"u8.ToArray());
message.AddAttachment("note.txt", attachmentStream, "text/plain");
using var output = File.Create("hello.msg");
message.Save(output);
Load a standard .eml file and save it as an Outlook .msg file using the built-in MIME parser.
using System.IO;
using Aspose.Email.Foss.Msg;
using var input = File.OpenRead("message.eml");
var message = MapiMessage.LoadFromEml(input);
using var msgOutput = File.Create("message.msg");
message.Save(msgOutput);
using var emlOutput = File.Create("roundtrip.eml");
message.SaveToEml(emlOutput);