会議リクエストの送信

Contents
[ ]

VSTO

Outlook のクラスを使用するには、.NET プロジェクトで Outlook.Interop を参照する必要があります。以下のコードスニペットは:

  1. ミーティングリクエストを作成します。
  2. 件名、本文、場所、時間などのプロパティを設定します。
  3. 受信者にミーティングリクエストを送信します。
  4. このサンプル アプリケーションが実行されるシステムに Microsoft Outlook がインストールされている必要があります。

 // 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

以下のコードは Aspose.Email for .NET を使用して会議依頼を送信します。まず、Aspose.Email.Appointment クラスで会議依頼を作成し、次にメールを送信し、会議依頼を添付して Aspose.Email.Mail.SmtpClient クラスでメールを送ります。

.NET 用 Aspose.Email を使用する利点

Outlook Interop を使用するには、使用するシステムに Microsoft Outlook がインストールされている必要があります。Aspose.Email for .NET は Outlook のインストールを必要とせず、サーバーアプリケーションに適しています。


  // Create attendees of the meeting

MailAddressCollection attendees = new MailAddressCollection();

attendees.Add("recipient1@domain.com");

attendees.Add("recipient2@domain.com");

// Set up appointment

Appointment app = new Appointment(

    "Location", // location of meeting

    DateTime.Now, // start date

    DateTime.Now.AddHours(1), // end date

    new MailAddress("organizer@domain.com"), // organizer

    attendees); // attendees

// Set up message that needs to be sent

MailMessage msg = new MailMessage();

msg.From = "from@domain.com";

msg.To = "to@domain.com";

msg.Subject = "appointment request";

msg.Body = "you are invited";

// Add meeting request to the message

msg.AddAlternateView(app.RequestApointment());

// Set up the SMTP client to send email with meeting request

SmtpClient client = new SmtpClient("host", 25 ,"user", "password");

client.Send(msg);

##サンプルコードのダウンロード