I have an area of my web application that was originally coded to use the Outlook.Interop ActiveX to bring up a new appointment and fill out the data necessary. This code, as you can image, this is no longer supported in most browsers and it is time to change this behavior.
My first thought was to simply code to create a message and appointment, save the message as a .msg file, and then redirect the user to that file. But when I code this, Outlook cannot send the file, it simply says “You cannot send this item”. It almost seems like if you try to do this independent of a connection to Exchange, the message does not have the information needed to send.
Pasted below is the test code I have tried.
private static void BuildAppointment(string sender, string recipientList, string body)
{
[//Aspose.Email.Clients.Exchange.WebService.IEWSClient](https://aspose.email.clients.exchange.webservice.iewsclient/) client = GetExchangeEWSClient(“https://outlook.office365.com/ews/exchange.asmx”, "someone@somewhere.com", “asdfasdf”);
MailAddressCollection recipients = new MailAddressCollection();
char[] delims = new char[] { ';', ',', '|', ' ' };
string[] addresses = recipientList.Split(delims, StringSplitOptions.RemoveEmptyEntries);
foreach (string recipient in addresses)
recipients.Add(new MailAddress(recipient));
//recipients.Add(new MailAddress(sender));
MailAddress organizer = new MailAddress(sender);
MailMessage message = new MailMessage();
message.To = recipients;
message.From = sender;
message.Subject = "Here is your appointment";
message.Body = message.Subject;
message.IsDraft = true;
Appointment app = new Appointment("My Office", new DateTime(2019, 12, 12, 13, 30, 00), new DateTime(2019, 12, 12, 14, 00, 00), organizer, recipients)
{
MethodType = AppointmentMethodType.Request
};
message.AddAlternateView(app.RequestApointment());
MapiMessage msg = MapiMessage.FromMailMessage(message);
//client.CreateAppointment(app);
msg.Save(body + ".msg");
msg.Dispose();
message.Dispose();
}
Any guidance would be greatly appreciated.