Zimbra TGZ ファイルの読み取りとエクスポート

Zimbra は、クラウドベースのメールおよびコラボレーションスイートで、メール、連絡先、カレンダー、ファイル共有、タスク、メッセージングを提供し、あらゆるデバイスから Zimbra Web クライアントでアクセスできます。

Aspose.Email for Node.js via .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 ファイル内のすべてのメッセージを保存できます。これはメールボックスデータの復元や移行時に便利です。

以下のコードサンプルは、Aspose.Email ライブラリを使用して TGZ アーカイブファイルからすべての Zimbra メールメッセージを抽出・エクスポートする方法を示します。

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.");