Free Support Forum - aspose.com

Adding appointments an E-Mail message

I need to be able to add multiple appointment requests to an email without using a recurrence pattern. Is this possible? I am able to add multiple appointment requests, but the resulting email only contains the first request that was added.

Hi,

Only one appointment request can be sent in an email. But if your attendees are using Outlook, you may use the following alternative approach, that sends ics files as attachments. If you open these ics files manually, Outlook can add these in the calendar.

// Create attemdees of the meeting
MailAddressCollection attendees = new MailAddressCollection();
attendees.Add("user1@domain.com");
attendees.Add("user2@domain.com");

// Setup appointment
Calendar app1 = new Calendar(
“Location 1”, // location of meeting
DateTime.Now, // start date
DateTime.Now.AddHours(1), // end date
new MailAddress("organizer@domain.com"), // organizer
attendees); // attendees
MemoryStream stream1 = new MemoryStream();
app1.Save(stream1);
stream1.Position = 0;

// Setup appointment
Calendar app2 = new Calendar(
“Location 2”, // location of meeting
DateTime.Now, // start date
DateTime.Now.AddHours(1), // end date
new MailAddress("organizer@domain.com"), // organizer
attendees); // attendees
MemoryStream stream2 = new MemoryStream();
app2.Save(stream2);
stream2.Position = 0;

// setup 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.AddAttachment(new Attachment(stream1, “app1.ics”));
msg.AddAttachment(new Attachment(stream2, “app2.ics”));

// setup smtp client to send email with meeting request
Aspose.Network.Mail.SmtpClient client = new SmtpClient(“smtp”);
client.Username = "user@domain.com";
client.Password =“pwd”;
client.Send(msg);