メール処理用 Node.js API
Node.js アプリケーション内で MSG、EML、EMLX、MHT などのメール形式を作成、操作、変換します。
Aspose.Email for Node.js via .NET は、柔軟でありながら強力なメールプログラミング API で、開発者の時間と労力を節約し、基盤フォーマット実装の複雑さを気にせずに一般的なメールメッセージ形式を作成、操作、変換できます。
インストール方法
簡単に実行 npm install @aspose/email 最新バージョンを取得し、以下のコードスニペットを試してください。
メッセージファイルを動的に変換
Aspose.Email for Node.js via .NET は、メールファイルの相互変換 API をお探しの場合に最適です。変換プロセス用の使いやすいインターフェイスを提供し、基になるフォーマット仕様の詳細を隠蔽します。必要なのは、Aspose.Email のオブジェクトモデルでソースファイルをロードし、適切なパラメータで Save メソッドを呼び出すだけです。本当にそれだけ簡単です!
MSG をさまざまな形式に変換
const ae = require('@aspose/email');
const msg= new ae.MailMessage.load(\"msgtemplate.msg\");
// MSG を EML、HTML、MHTML 形式に変換 msg.save(\"emloutput.eml\", SaveOptions.defaultEml); msg.save(\"htmloutput.html\", SaveOptions.defaultHtml); msg.save(\"mhtoutput.mhtml\", SaveOptions.defaultMhtml) 予定の ICS フォーマットに対する幅広いサポート
Aspose.Email for Node.js via .NET を使用すると、予定を作成してICS形式で保存できます。Node.js Email Library は、ICSファイルから予定をロードし、予定イベントの読み書きを行い、ドラフトとして予定を作成し、参加者のステータスを設定することも可能です。
予定を作成して保存する
const ae = require('@aspose/email');
const attendees = new ae.MailAddressCollection(); attendees.add(new ae.MailAddress(\"person1@domain.com\")); attendees.add(new ae.MailAddress(\"person2@domain.com\")); attendees.add(new ae.MailAddress(\"person3@domain.com\"));
// create const app = new ae.Calendar.Appointment(\"Room 112\", new Date(2006, 6, 17, 13, 0, 0), new Date(2006, 6, 17, 14, 0, 0), new ae.MailAddress(\"somebody@domain.com\"), attendees);
app.summary = \"Release Meetting\"; app.description = \"Discuss for the next release\";
// ICS として保存 const options = new ae.Calendar.AppointmentIcsSaveOptions(); // デフォルトの ICS オプションを使用 app.save(\"AppointmentInICSFormat_out.ics\", options); 予定をロード
const ae = require('@aspose/email');
const loadedAppointment = ae.Calendar.Appointment.load(\"Appointment.ics\"); // 画面に予定情報を表示 console.log(\"Summary: \", loadedAppointment.summary); console.log(\"Location: \", loadedAppointment.location); console.log(\"Description: \", loadedAppointment.description); console.log(\"Start date::\", loadedAppointment.startDate); console.log(\"End date:\", loadedAppointment.endDate); console.log(\"Organizer: \", loadedAppointment.organizer); console.log(\"Attendees: \", loadedAppointment.attendees); iCalendar API で会議を生成および利用
Aspose.Email for Node.js via .NET は、MSG および ICS 形式で Outlook カレンダー項目を生成および保存する機能を提供します。iCalendar オブジェクトの作成と保存だけでなく、取得、更新、送信、キャンセルも可能です。さらに、直感的なオブジェクトモデルにより、iCalendar RFC 2445 形式の繰り返しパターンを動的に生成・利用することが容易です。
予定リクエストを作成。詳細を見る こちら
const ae = require('@aspose/email');
const appWhere = \"location\"; const appWhen = new Date(2023, 8, 17, 13, 0, 0); const sender = new ae.MailAddress(\"from@domain.com\"); const recipient = new ae.MailAddress(\"to@domain.com\"); const attendees = new ae.MailAddressCollection(); attendees.add(recipient);
const app = new ae.Calendar.Appointment(appWhere, appWhen, appWhen, sender, attendees);
const message = new ae.MailMessage(sender, recipient); message.addAlternateView(app.requestApointment()); const msg = ae.Mapi.MapiMessage.fromMailMessage(message);
// Save the appointment. msg.save(\"appointment.msg\"); PST、OST、MBOX ファイルの作成または操作
Aspose.Email for Node.js via .NET は、PST & OST などの Outlook ストレージファイルの管理を可能にします。既存のストレージファイルに対してさまざまな操作を実行でき、新規 PST ファイルをゼロから作成することもできます。可能な操作にはフォルダー一覧、メッセージ一覧、メッセージ抽出、MSG 形式の連絡先があります。
PST を読み込む
const ae = require('@aspose/email');
const pst = ae.Storage.Pst.PersonalStorage.fromFile(\"outlook.pst\"); const rootFolders = pst.rootFolder.getSubFolders();
for( folder of rootFolders) { console.log(\"Folder: \", folder.displayName); console.log(\"Total Items: \", folder.contentCount); console.log(\"Total Unread Items: \", folder.contentUnreadCount); console.log(\"----------------------\"); for(msg of folder.enumerateMessages()) { console.log(\" \", msg.subject); } } Outlook ストレージファイルに加えて、Aspose.Email for Node.js via .NET は Mbox ファイル形式もサポートします。既存の Mbox ファイルをロードし、メッセージ情報を抽出できます。
Mbox からメッセージを抽出
var ae = require('@aspose/email');
const options = new ae.Storage.Mbox.MboxLoadOptions(); // using default options const reader = new ae.Storage.Mbox.MboxrdStorageReader(\"Inbox.mbox\", options); let index = 0; // Read all messages in a loop for(eml of reader.enumerateMessages() ) { console.log(\"Subject: \", eml.subject);
// save message in EML & MSG format
eml.save(`${index}_output.eml`, ae.SaveOptions.defaultEml);
eml.save(`${index}_output.msg`, ae.SaveOptions.defaultMsgUnicode);
++index;
}