Aspose.Email  .NET 経由の Node.js 用

メール処理用の Node.js API

Node.js アプリケーション内から MSG、EML、EMLX、MHT などの電子メール形式を作成、操作、または変換します。

 
  
 

.NET 経由の Aspose.Email for Node.js は、柔軟でありながら強力な電子メールプログラミング API です。これにより、基盤となる形式の実装の複雑さを気にすることなく、開発者が一般的な電子メールメッセージ形式を作成、操作、または変換する時間と労力を節約できます。

インストール方法
実行するだけ npm インストール @aspose /email 最新バージョンを入手して、次のコードスニペットのいずれかを試してください。

メッセージファイルの動的変換

メールファイルを相互変換する API を探しているなら、.NET 経由の Node.js 用の Aspose.Email が適しています。変換プロセスに使いやすいインターフェイスを提供すると同時に、基礎となるフォーマット仕様の醜い詳細をすべて隠すことができます。必要なことは、ソースファイルを Aspose.Email オブジェクトモデルに読み込み、適切なパラメーターを指定して Save メソッドを呼び出すことだけです。本当に簡単です!

MSGをさまざまな形式に変換

const ae = require('@aspose/email');

const msg= new ae.MailMessage.load("msgtemplate.msg");

// convert MSG to EML, HTML & MHTML formats
msg.save("emloutput.eml", SaveOptions.defaultEml);
msg.save("htmloutput.html", SaveOptions.defaultHtml);
msg.save("mhtoutput.mhtml", SaveOptions.defaultMhtml)
     

アポイントメントICSフォーマットの広範なサポート

.NET 経由の Aspose.Email for Node.js を使用して予定を作成し、ICS 形式で保存できます。Node.js メールライブラリでは、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";

// save as ICS
const options = new ae.Calendar.AppointmentIcsSaveOptions(); // use default ICS options
app.save("AppointmentInICSFormat_out.ics", options);
     

予定を読み込む

const ae = require('@aspose/email');

const loadedAppointment = ae.Calendar.Appointment.load("Appointment.ics");
// Display the appointment information on screen
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 によるミーティングの制作と利用

.NET 経由の Node.js 用の Aspose.Email には、Outlook 予定表アイテムを MSG 形式と ICS 形式で生成して保存する機能があります。iCalendar オブジェクトを作成して保存できるだけでなく、会議出席依頼を取得、更新、送信、キャンセルすることもできます。さらに、直感的なオブジェクトモデルを使用すると、iCalendar RFC 2445 形式の繰り返しパターンを動的に生成して使用することも簡単です。

アポイントメントリクエストを作成します。詳細を見る here

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 ファイルの作成または操作

.NET 経由の Node.js 用の Aspose.Email を使用すると、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 ストレージファイルに加えて、.NET 経由の Aspose.Email for Node.js は Mbox ファイル形式もサポートしています。.NET 経由で Aspose.Email for Node.js を使用すると、既存の 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;
}
      
  
  

Aspose.Emailは、以下に示すように、他の一般的な開発環境向けに個別のメールAPIを提供します。