Enviando solicitud de reunión usando Outlook Interop y Aspose.Email for Java

Enviando solicitud de reunión con Outlook Interop

Para usar clases de Outlook, Outlook.Interop debe ser referenciado en su proyecto .NET. El fragmento de código a continuación:

  1. Crea una solicitud de reunión.
  2. Establece propiedades como asunto, cuerpo, ubicación y hora.
  3. Envía la solicitud de reunión al destinatario.

Microsoft Outlook debe estar instalado en el sistema donde esta aplicación de ejemplo se ejecutará.

Ejemplos de programación

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

Enviando solicitud de reunión usando Aspose.Email for Java

El código a continuación usa Aspose.Email for Java para enviar una solicitud de reunión. Primero, cree la solicitud de reunión usando el Aspose.Email Appointment clase. Luego envíe el correo, adjunte la solicitud de reunión y envíe el correo usando el Aspose.Email SmtpClient clase.

Ventajas de usar Aspose.Email for Java

Outlook Interop requiere que Microsoft Outlook esté instalado en el sistema donde se usa. Aspose.Email for Java no requiere que Microsoft Outlook esté instalado y es adecuado en aplicaciones de servidor.

Ejemplos de programación


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