שליחת בקשת פגישה באמצעות Outlook Interop ו‑Aspose.Email for Java
טיפי המיגרציה שלנו מראות כיצד ניתן להשתמש במוצרים של Aspose כדי לשפר את היישומים שלכם ולשחרר אתכם מהתלות באוטומציה מסורתית.
טיפ מיגרציה זה שולח בקשת פגישה לנמען. הוא מדגים כיצד לשלוח בקשת פגישה בשתי דרכים:
אנו נידון גם ביתרות של הגישה השנייה.
שליחת בקשת פגישה באמצעות Outlook Interop
כדי להשתמש במחלקות Outlook, יש להפנות ל‑Outlook.Interop בפרויקט .NET שלך. קטע הקוד למטה:
- יוצר בקשת פגישה.
- מגדיר מאפיינים כמו נושא, גוף, מיקום וזמן.
- שולח את בקשת הפגישה לנמען.
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);
}