อ่านและส่งออกไฟล์ Zimbra TGZ
Zimbra คือชุดอีเมลและการทำงานร่วมกันบนคลาวด์ที่ให้บริการอีเมล, รายชื่อผู้ติดต่อ, ปฏิทิน, การแชร์ไฟล์, งานและข้อความ - ทั้งหมดนี้เข้าถึงได้ผ่าน Zimbra Web Client บนอุปกรณ์ใดก็ได้
Aspose.Email for Node.js ผ่าน .NET ทำให้ผู้พัฒนาสามารถอ่าน, ดึงและส่งออกข้อมูลจากไฟล์สำรอง Zimbra TGZ โดยใช้ TgzReader คลาส คุณสามารถเข้าถึงข้อความทั้งหมด, นับรายการทั้งหมด, และส่งออกข้อความ, รายชื่อผู้ติดต่อ หรือข้อมูลปฏิทินจากไฟล์ TGZ ไปยังรูปแบบทั่วไปได้อย่างง่ายดาย
อ่านข้อความทั้งหมดจากไฟล์ Zimbra TGZ
นี้ TgzReader คลาสนี้ช่วยให้คุณอ่านข้อความทั้งหมดที่เก็บไว้ในไฟล์สำรอง Zimbra TGZ
ตัวอย่างต่อไปนี้แสดงวิธีวนผ่านข้อความทั้งหมดและแสดงตำแหน่งโฟลเดอร์และหัวข้อของแต่ละข้อความ
const asposeemail = require('@aspose/email');
const fs = require('fs');
// Path to the Zimbra TGZ file
const tgzPath = "ZimbraSample.tgz";
// Create a TgzReader instance
const reader = new asposeemail.TgzReader(tgzPath);
// Read and display all messages
while (reader.readNextMessage()) {
const directoryName = reader.currentDirectory;
console.log("Directory:", directoryName);
const message = reader.currentMessage;
console.log("Subject:", message.subject);
}
reader.dispose();
console.log("All messages read successfully from the Zimbra TGZ file.");
นับจำนวนรายการทั้งหมดในไฟล์ Zimbra TGZ
คุณสามารถกำหนดจำนวนรายการอีเมลที่มีอยู่ในสำรองข้อมูล TGZ ได้อย่างรวดเร็วโดยใช้ getTotalItemsCount() เมธอดของ TgzReader คลาส.
ตัวอย่างโค้ดต่อไปนี้จะแสดงวิธีใช้งานเมธอดนี้ในโครงการของคุณ:
const asposeemail = require('@aspose/email');
const tgzFile = "ZimbraSample.tgz";
const reader = new asposeemail.TgzReader(tgzFile);
const totalCount = reader.getTotalItemsCount();
console.log(`Total items in TGZ file: ${totalCount}`);
reader.dispose();
บันทึกข้อความและโครงสร้างโฟลเดอร์จากไฟล์ Zimbra TGZ
นี้ exportTo() เมธอดนี้ช่วยให้คุณบันทึกข้อความทั้งหมดจากไฟล์ TGZ พร้อมคงโครงสร้างโฟลเดอร์เดิม ซึ่งมีประโยชน์เมื่อทำการกู้คืนหรือย้ายข้อมูลกล่องจดหมาย
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีดึงและส่งออกอีเมลทั้งหมดของ Zimbra จากไฟล์ TGZ โดยใช้ไลบรารี Aspose.Email
const asposeemail = require('@aspose/email');
const tgzFile = "ZimbraSample.tgz";
const outputDir = "Output/Zimbra/";
const reader = new asposeemail.TgzReader(tgzFile);
reader.exportTo(outputDir);
reader.dispose();
console.log(`All Zimbra messages exported to: ${outputDir}`);
ส่งออกปฏิทินและรายชื่อผู้ติดต่อจากไฟล์สำรอง Zimbra
การสำรองข้อมูล Zimbra TGZ อาจรวมโฟลเดอร์รายชื่อผู้ติดต่อและปฏิทิน คุณสามารถส่งออกเหล่านี้เป็นรูปแบบ VCard (.vcf) และ iCalendar (.ics) โดยใช้วิธีเดียวกัน exportTo() เมธอด.
const asposeemail = require('@aspose/email');
const tgzFile = "ZimbraBackup.tgz";
const outputPath = "Output/ZimbraData/";
const reader = new asposeemail.TgzReader(tgzFile);
// Contacts can be found in "Contacts" and "Emailed Contacts" folders.
// Calendar entries can be found in the "Calendar" folder.
reader.exportTo(outputPath);
reader.dispose();
console.log("Zimbra calendar and contacts exported successfully.");