การแปลง MBOX เป็น PST

แปลง MBOX เป็น PST การแปลงพื้นฐาน

เมื่อต้องย้ายข้อมูลเมลจากไคลเอนต์เช่น Mozilla Thunderbird ไปยัง Microsoft Outlook การแปลงอาร์ไคฟ์ MBOX เป็นรูปแบบ PST (Personal Storage Table) มักจำเป็น รูปแบบ PST เป็นรูปแบบดั้งเดิมของ Outlook และ Exchange และรองรับฟีเจอร์ขั้นสูงเช่นโครงสร้างโฟลเดอร์และการจัดการข้อความแบบ MAPI

Aspose.Email สำหรับ .NET อนุญาตให้นักพัฒนาทำการโอนย้ายข้อความจากไฟล์ MBOX ไปยัง storage ที่เข้ากันได้กับ Outlook ด้วยการควบคุมเต็มที่ของกระบวนการแปลง ด้านล่างเป็นตัวอย่างที่แสดงวิธีโหลดข้อความจากอาร์ไคฟ์ MBOX และบันทึกลงในไฟล์ข้อมูล Outlook ที่มีโครงสร้าง:

  1. เริ่มต้นตัวอ่าน MBOX โดยใช้ MboxStorageReader.CreateReader().
  2. สร้างไฟล์ PST ด้วยการใช้ PersonalStorage.Create().
  3. เพิ่มโฟลเดอร์เมล (เช่น “Inbox”) ลงใน storage.
  4. วนลูปผ่านแต่ละข้อความ แปลงเป็น MapiMessage, และใส่ลงในโฟลเดอร์
// Load the source file
var mbox = MboxStorageReader.CreateReader(mboxFilePath, new MboxLoadOptions());

// Create the destination Outlook data file
using (var personalStorage = PersonalStorage.Create(pstFilePath, FileFormatVersion.Unicode))
{
    // Add a folder to hold imported messages
    var folderInfo = personalStorage.CreatePredefinedFolder("Inbox", StandardIpmFolder.Inbox);

    // Process each message from the source file
    foreach (var eml in mbox.EnumerateMessages())
    {
        var msg = MapiMessage.FromMailMessage(eml);
        folderInfo.AddMessage(msg);
    }
}

ลบลายเซ็นดิจิทัลระหว่างการแปลง

ในบางกรณีลายเซ็นดิจิทัลที่ฝังอยู่ในข้อความไม่จำเป็นในไฟล์เป้าหมาย เพื่อลบออกระหว่างการโอนย้าย ให้ตั้งค่า RemoveSignature คุณสมบัติใน MboxToPstConversionOptions เป็น true.

ตัวอย่างโค้ดต่อไปนี้แสดงวิธีการใช้คุณสมบัตินี้:

var pstDataStream = new MemoryStream();
var personalStorage = PersonalStorage.Create(pstDataStream, FileFormatVersion.Unicode);
MailStorageConverter.MboxToPst(new MboxrdStorageReader(new FileStream(fileName, FileMode.Open, FileAccess.Read), new MboxLoadOptions()),
personalStorage,
    "Inbox",
new MboxToPstConversionOptions() { RemoveSignature = true });