Free Support Forum - aspose.com

Create/Upadate/Read and send OutLook Appointment

Hello,
there is an example "Load and Save Appointment in ICS Format"
http://www.aspose.com/docs/display/emailnet/Load+and+Save+Appointment+in+ICS+Format

1. Is there an example of how to send appointment to Outlook users?
User must reseive standart outllook appoiment, and can accept or reject. Appoiment must work on Outlook web inerface too.

2. Is it posible to read user answer (accept or reject) of sended appointment?
The user answer (accept or reject) is the message, right? Is it posible to read it using ASPOSE?
There must be an UID of appoiment that will generated when sending, is it possible to read it using ASPOSE?

Hi Igotta,


We are sorry for the delayed response.

Following is the example which can be used to send appointment to Outlook users. It is received as standard outlook appointment and user can accept or reject this appointment. Appointment unique


Appointment app = new Appointment(“Appointment Location”, DateTime.Now.AddDays(1), DateTime.Now.AddDays(1).AddHours(1), "user1@domain.com", "user2@domain.com");
app.Summary = “Appointment Summary”;
app.Description = “Appointmnet Description”;

// create the message and set the meeting request
MailMessage msg = new MailMessage();
msg.From = "user1@domain.com";
msg.To = "user2@domain.com";
msg.TextBody = “Message Text: Hi you are invited here please”;
msg.Subject = “Message Subject: Meeting request subject”;
msg.AddAlternateView(app.RequestApointment());

// Save appointment unique id for later use
strSentAppUniqueId = app.UniqueId;
System.IO.File.WriteAllText(@“SentAppUniqueId.txt”, strSentAppUniqueId);

// Send the appointment
ExchangeWebServiceClient clientSender = new ExchangeWebServiceClient(“https://exchange.domain.com/ews/Exchange.asmx”, “user1”, “password”, “”);
clientSender.Send(msg);

Aspose.Email supports reading appointments from the calendar folder. Following is the sample code which can be used to read the appointments and their unique id as saved in text file before sending in the above mentioned code.

ExchangeWebServiceClient clientSender = new ExchangeWebServiceClient(“https://exchange.domain.com/ews/Exchange.asmx",“User1”,"Password, “”);
ExchangeMailboxInfo clientSenderMBInfo = clientSender.GetMailboxInfo();
foreach (ExchangeMessageInfo messageInfo in clientSender.ListMessages(clientSenderMBInfo.CalendarUri))
{
Appointment fetchedAppointment = clientSender.FetchAppointment(messageInfo.UniqueUri);
// Same unique id as saved text file in previous example
Console.WriteLine("Unique Id = " + fetchedAppointment.UniqueId);
}

Please give try to the above mentioned code and let us know your feedback

Hi Igotta,


Following is another sample for reading the accepted appointments using ImapClient. It reads filtered messages from inbox whose subject starts from “Accepted:” for accepted meetings.

You can also filter rejected meetings by using filter string “Declined:” and tentative meetings by using string “Tentatively Accepted:”.

The meeting replies messages contain alternate view whose ContentType.MediaType is “text/calendar”. This media type filter can be used to extract the appointment and respective unique id.


static void ReadAppointmentReplies()
{
ImapClient client = new ImapClient(“exchange.domain.com”, 993, “user”, “passord”);

// set the security mode to explicit
client.SecurityMode = ImapSslSecurityMode.Implicit;

// enable SSL
client.EnableSsl = true;

// connect to imap server and login
client.Connect(true);
client.SelectFolder(“Inbox”);

// Set conditions
ImapQueryBuilder builder = new ImapQueryBuilder();

// Subject contains “Accepted:”
builder.Subject.Contains(“Accepted:”);

// Build the query
MailQuery query = builder.GetQuery();
ImapMessageInfoCollection msgCollection = client.ListMessages(query);
foreach (ImapMessageInfo info in msgCollection)
{
//Fetch Message
Aspose.Email.Mail.MailMessage msg = client.FetchMessage(info.UniqueId);
foreach (AlternateView alterView in msg.AlternateViews)
{
if (alterView.ContentType.MediaType == “text/calendar”)
{
//Convert message body to stream
//byte[] byteArray = Encoding.ASCII.GetBytes(msg.Body.ToCharArray());
//MemoryStream stream = new MemoryStream(byteArray);
//Appointment app = Appointment.Load(stream);

//Extract calender as appointment
Appointment app = Appointment.Load(alterView.ContentStream);
Console.WriteLine("Appointment unique id = " + app.UniqueId);
}
}
}
}