เริ่มต้นใช้งาน
เริ่มต้นใช้งาน Aspose.Email FOSS สำหรับ .NET
ยินดีต้อนรับสู่ Aspose.Email FOSS for .NET, ไลบรารี C# ฟรีที่มีใบอนุญาต MIT สำหรับการอ่าน, สร้าง และเขียนไฟล์ Outlook MSG, คอนเทนเนอร์ Compound File Binary (CFB) และ EML ข้อความ. คู่มือฉบับนี้พาคุณจากโครงการ .NET ใหม่ไปสู่การทำงานกับไฟล์ MSG ภายในไม่กี่นาที.
ข้อกำหนดเบื้องต้น
| ข้อกำหนด | รายละเอียด |
|---|---|
| .NET | 8.0 หรือใหม่กว่า |
| ตัวจัดการแพคเกจ | NuGet (dotnet CLI หรือ Visual Studio) |
| ระบบปฏิบัติการ | Windows, macOS หรือ Linux |
| การพึ่งพา | ไม่มี — pure managed C# |
การติดตั้ง
ติดตั้งจาก NuGet:
dotnet add package Aspose.Email.Fossตรวจสอบในแอปคอนโซลขนาดเล็ก:
using Aspose.Email.Foss.Msg;
var message = MapiMessage.Create("Test", "Hello");
Console.WriteLine($"Subject: {message.Subject}");
// Output: Subject: Testดู คู่มือการติดตั้ง สำหรับรายละเอียดการตั้งค่าโครงการ.
สิ่งที่คุณทำได้
เมื่อติดตั้งแล้วคุณสามารถทำได้ทันที:
- อ่าน MSG files with
MapiMessage.FromStream()orMapiMessage.FromFile()— access subject, body, HTML body, sender, recipients, and attachments - สร้าง MSG messages from scratch with
MapiMessage.Create()— set all fields, add recipients and attachments, then serialize withmessage.Save() - แปลง between MSG and EML (MIME/RFC 5322) with
LoadFromEml()andSaveToEml() - ตรวจสอบ the underlying CFB binary container with
CfbReader— traverse storages and streams, resolve paths, read raw bytes - เขียน CFB documents with
CfbWriterfor forensic inspection or format construction - จัดการไฟล์แนบ — add file, stream, or embedded MSG attachments with full metadata
เริ่มต้นอย่างรวดเร็ว
อ่านไฟล์ MSG และพิมพ์หัวเรื่องและผู้รับ:
using System.IO;
using Aspose.Email.Foss.Msg;
using var stream = File.OpenRead("sample.msg");
var message = MapiMessage.FromStream(stream);
Console.WriteLine($"Subject: {message.Subject}");
Console.WriteLine($"From: {message.SenderEmailAddress}");
foreach (var recipient in message.Recipients)
Console.WriteLine($"To: {recipient.EmailAddress}");
foreach (var attachment in message.Attachments)
Console.WriteLine($"Attachment: {attachment.Filename} ({attachment.MimeType})");ขั้นตอนต่อไป
- Installation Guide: รายละเอียดการตั้งค่าโครงการและการติดตั้ง NuGet
- Developer Guide: การดำเนินการ MSG, ไฟล์แนบ, คุณสมบัติ MAPI, และโครงสร้าง CFB
- Features: การสำรวจเชิงลึกทุกฟีเจอร์พร้อมตัวอย่าง C#