Outlook Interop と Aspose.Email for Java を使用したミーティングリクエストの送信
Contents
[
Hide
]
私たちのマイグレーションチップは、Aspose 製品を使用してアプリケーションを改善し、従来の自動化への依存から解放できる方法を示しています。
この移行ヒントは受信者にミーティングリクエストを送信します。ミーティングリクエストを送信する二つの方法を示しています:
後者のアプローチの利点についても説明します。
Outlook Interop を使用したミーティングリクエストの送信
Outlook のクラスを使用するには、.NET プロジェクトで Outlook.Interop を参照する必要があります。以下のコードスニペットは:
- ミーティングリクエストを作成します。
- 件名、本文、場所、時間などのプロパティを設定します。
- 受信者にミーティングリクエストを送信します。
このサンプル アプリケーションが実行されるシステムに Microsoft Outlook がインストールされている必要があります。
プログラミングサンプル
C#
// Create an instance of Outlook Application class
Outlook.Application outlookApp = new Outlook.Application ();
// Create an instance of AppointmentItem object and set the properties:
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem) outlookApp.CreateItem (Outlook.OlItemType.olAppointmentItem);
oAppointment.Subject = "subject of appointment";
oAppointment.Body = "body text of appointment";
oAppointment.Location = "Appointment location";
// Set the start date and end dates
oAppointment.Start = Convert.ToDateTime ("01/22/2010 10:00:00 AM");
oAppointment.End = Convert.ToDateTime("01/22/2010 2:00:00 PM");
// Save the appointment
oAppointment.Save ();
// Send the appointment
Outlook.MailItem mailItem = oAppointment.ForwardAsVcal ();
mailItem.To = "recipient@domain.com";
mailItem.Send();
Aspose.Email for Java を使用したミーティングリクエストの送信
以下のコードは Aspose.Email for Java を使用してミーティングリクエストを送信します。まず、次を使用してミーティングリクエストを作成します Aspose.Email Appointment クラスです。その後、メールを送信し、ミーティングリクエストを添付して、次を使用してメールを送ります Aspose.Email SmtpClient クラス。
Aspose.Email for Java の利点
Outlook Interop は使用するシステムに Microsoft Outlook がインストールされていることが必要です。Aspose.Email for Java は Microsoft Outlook のインストールを必要とせず、サーバーアプリケーションに適しています。
プログラミングサンプル
// Create attendees of the meeting
MailAddressCollection attendees = new MailAddressCollection();
attendees.add("recipient1@domain.com");
attendees.add("recipient2@domain.com");
java.util.Calendar c = java.util.Calendar.getInstance();
Date startDate = c.getTime();
c.add(java.util.Calendar.HOUR_OF_DAY, 1);
Date endDate = c.getTime();
// Set up appointment
Appointment app = new Appointment(
"Location", // location of meeting
startDate, // start date
endDate, // end date
new MailAddress("organizer@domain.com"), // organizer
attendees); // attendees
// Set up message that needs to be sent
MailMessage msg = new MailMessage();
msg.setFrom(new MailAddress("from@domain.com"));
msg.setTo(MailAddressCollection.to_MailAddressCollection("to@domain.com"));
msg.setSubject("appointment request");
msg.setBody("you are invited");
// Add meeting request to the message
msg.addAlternateView(app.requestApointment());
// Set up the SMTP client to send email with meeting request
try (SmtpClient client = new SmtpClient("host", 25, "user", "password")) {
client.send(msg);
}