Đọc và Xuất tệp Zimbra TGZ
Zimbra là một bộ ứng dụng email và hợp tác dựa trên đám mây cung cấp email, danh bạ, lịch, chia sẻ tệp, nhiệm vụ và tin nhắn - tất cả có thể truy cập qua Zimbra Web Client trên bất kỳ thiết bị nào.
Aspose.Email cho Node.js qua .NET cho phép các nhà phát triển đọc, trích xuất và xuất dữ liệu từ tệp sao lưu Zimbra TGZ bằng cách sử dụng TgzReader lớp. Bạn có thể dễ dàng truy cập tất cả các tin nhắn, đếm tổng số mục, và xuất tin nhắn, danh bạ hoặc dữ liệu lịch từ tệp TGZ sang các định dạng phổ biến.
Đọc Tất cả Tin nhắn từ Tệp Zimbra TGZ
Cái TgzReader lớp cho phép bạn đọc tất cả các tin nhắn lưu trong tệp sao lưu Zimbra TGZ.
Ví dụ sau đây minh họa cách duyệt qua tất cả các tin nhắn và hiển thị vị trí thư mục và chủ đề của chúng.
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.");
Đếm Tổng số Mục trong Tệp Zimbra TGZ
Bạn có thể nhanh chóng xác định có bao nhiêu mục email tồn tại trong sao lưu TGZ bằng cách sử dụng getTotalItemsCount() phương thức của TgzReader lớp.
Đoạn mã mẫu dưới đây sẽ cho bạn thấy cách thực hiện phương thức này trong dự án của bạn:
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();
Lưu Tin nhắn và Cấu trúc Thư mục từ Tệp Zimbra TGZ
Cái exportTo() phương thức cho phép bạn lưu tất cả các tin nhắn từ tệp TGZ đồng thời duy trì cấu trúc thư mục gốc. Điều này hữu ích khi khôi phục hoặc di chuyển dữ liệu hộp thư.
Đoạn mã mẫu dưới đây minh họa cách trích xuất và xuất tất cả các tin nhắn email Zimbra từ tệp lưu trữ TGZ bằng thư viện 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}`);
Xuất Lịch và Danh bạ từ Tệp sao lưu Zimbra
Sao lưu Zimbra TGZ có thể bao gồm các thư mục danh bạ và lịch. Bạn có thể xuất chúng sang định dạng VCard (.vcf) và iCalendar (.ics) bằng cùng exportTo() phương thức.
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.");