Aspose.Email  cho Node.js thông qua .NET

API Node.js để xử lý email

Tạo, thao tác hoặc chuyển đổi các định dạng email bao gồm MSG, EML, EMLX & MHT từ trong các ứng dụng Node.js.

 
  
 

Aspose.Email cho Node.js thông qua .NET là một API lập trình email linh hoạt nhưng mạnh mẽ, giúp tiết kiệm thời gian và công sức của nhà phát triển để tạo, thao tác hoặc chuyển đổi các định dạng thư email phổ biến mà không phải lo lắng về sự phức tạp của việc triển khai định dạng cơ bản.

Làm thế nào để cài đặt
Đơn giản chỉ cần thực hiện npm cài đặt @aspose /email để có được phiên bản mới nhất và thử bất kỳ đoạn mã nào sau đây.

Tự động chuyển đổi tệp tin nhắn

Aspose.Email cho Node.js thông qua .NET là một lựa chọn tốt nếu bạn đang tìm kiếm một API để chuyển đổi các tệp email. Nó cung cấp các giao diện dễ sử dụng cho quá trình chuyển đổi trong khi ẩn tất cả các chi tiết xấu xí của đặc tả định dạng cơ bản. Tất cả những gì bạn cần làm là tải tệp nguồn trong mô hình đối tượng Aspose.Email và gọi phương thức Save với các tham số thích hợp. Nó thực sự đơn giản như vậy!

Chuyển đổi MSG sang các định dạng khác nhau

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)
     

Hỗ trợ rộng rãi cho Định dạng ICS cuộc hẹn

Aspose.Email cho Node.js thông qua .NET có thể được sử dụng để tạo các cuộc hẹn và lưu chúng ở định dạng ICS. Thư viện Email Node.js cũng cho phép tải các cuộc hẹn từ các tệp ICS, đọc hoặc viết các sự kiện cuộc hẹn, tạo một cuộc hẹn dưới dạng bản nháp và đặt trạng thái người tham gia của người tham dự cuộc hẹn.

Tạo và lưu các cuộc hẹn

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

Tải một cuộc hẹn

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

Tạo và tiêu thụ các cuộc họp với API iCalendar

Aspose.Email cho Node.js thông qua .NET cung cấp chức năng để tạo và lưu các mục Lịch Outlook ở định dạng MSG và ICS. Bạn không chỉ có thể tạo và lưu các đối tượng iCalendar mà còn truy xuất, cập nhật, gửi và hủy yêu cầu họp. Hơn nữa, sử dụng mô hình đối tượng trực quan, thật dễ dàng để tự động sản xuất và sử dụng các mẫu lặp lại ở định dạng iCalendar RFC 2445.

Tạo Yêu cầu cuộc hẹn. Xem chi tiết 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");           
     

Tạo hoặc thao tác các tệp PST, OST & MBOX

Aspose.Email cho Node.js thông qua .NET cho phép bạn quản lý các tệp lưu trữ Outlook như PST & OST. Bạn có thể thực hiện một số thao tác trên các tệp lưu trữ hiện có cũng như tạo các tệp PST mới từ đầu. Các hoạt động có thể bao gồm danh sách thư mục, danh sách tin nhắn, trích xuất tin nhắn và danh bạ ở định dạng MSG.

Đọc 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);
    }
}
     

Cùng với các tệp lưu trữ Outlook, Aspose.Email cho Node.js thông qua .NET cũng hỗ trợ định dạng tệp Mbox. Bạn có thể sử dụng Aspose.Email cho Node.js thông qua .NET để tải các tệp Mbox hiện có và trích xuất thông tin thư.

Trích xuất tin nhắn từ 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 cung cấp các API Email riêng lẻ cho các môi trường phát triển phổ biến khác như được liệt kê dưới đây: