joein610
asked on
How do I create outlook appointments with c# in exchange?
What is the easiest way to get it to work? I've been playing with Microsoft.Exchange.WebServ ices.Data; and it seems like this is the way to go.
http://www.codeproject.com/KB/applications/SendAppointment.aspx
This is the documentation for creating appointments with the EWS Managed API:
http://msdn.microsoft.com/en-us/library/dd633661(v=exchg.80).aspx#Y100
I assume that you are writing a server app, so you'll need to to create appointments for other users. In which case, you'll also need to incorporate impersonation:
http://msdn.microsoft.com/en-us/library/dd633680(EXCHG.80).aspx
If you are writing a client app, just use the Outlook Object Model. This example is VB.NET, but you get the idea... http://support.microsoft.com/kb/313788
http://msdn.microsoft.com/en-us/library/dd633661(v=exchg.80).aspx#Y100
I assume that you are writing a server app, so you'll need to to create appointments for other users. In which case, you'll also need to incorporate impersonation:
http://msdn.microsoft.com/en-us/library/dd633680(EXCHG.80).aspx
If you are writing a client app, just use the Outlook Object Model. This example is VB.NET, but you get the idea... http://support.microsoft.com/kb/313788
ASKER
Thank you for all the info. I'm trying to get it to work but it gets me an error all the time. I attached the API dll file but it seems like it doesn't work properly. Take a look at the screen shots
3-8-2011-8-58-55-AM.png
3-8-2011-8-59-45-AM.png
3-8-2011-8-58-55-AM.png
3-8-2011-8-59-45-AM.png
Looks like you added the reference correctly, so I don't see why Visual Studio is complaining. Is Microsoft.Exchange.WebServ ices in the Object Browser (like in my screen shot)?
objectbrowser.JPG
objectbrowser.JPG
ASKER
Yes it is. Is there anything else I can do to try to get this to work?
ASKER
This is how it looks like..
3-9-2011-8-52-29-AM.png
3-9-2011-8-52-29-AM.png
Try building my project file. It assumes that the Microsoft.Exchange.WebServ ices.dll is in a subfolder named "EWS".
EwsManagedTest.csproj Program.cs
EwsManagedTest.csproj Program.cs
ASKER
Good Morning, I tried yours but I got another error. I'm attaching my project + the screen shoot of the error.
The whole project is located here: http://www.nerdalert.biz/exchange.rar
3-14-2011-10-41-20-AM.png
The whole project is located here: http://www.nerdalert.biz/exchange.rar
3-14-2011-10-41-20-AM.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It worked. Thank you very much for your help. This is my code for any future reference:
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptograp hy.X509Cer tificates;
using Microsoft.Exchange.WebServ ices.Data;
namespace EwsManagedTest
{
class Program
{
static void Main(string[] args)
{
ServicePointManager.Server Certificat eValidatio nCallback +=
delegate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
};
string userName = "login";
string password = "password";
string domain = "domain.com";
string exchangeWebServiceUrl = "IPADDRESS/ews/exchange.as mx";
ExchangeService service = new ExchangeService();
service.Credentials = new WebCredentials(userName, password, domain);
service.Url = new Uri(exchangeWebServiceUrl) ;
Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours (1);
appointment.Save();
}
}
}
using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptograp
using Microsoft.Exchange.WebServ
namespace EwsManagedTest
{
class Program
{
static void Main(string[] args)
{
ServicePointManager.Server
delegate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
};
string userName = "login";
string password = "password";
string domain = "domain.com";
string exchangeWebServiceUrl = "IPADDRESS/ews/exchange.as
ExchangeService service = new ExchangeService();
service.Credentials = new WebCredentials(userName, password, domain);
service.Url = new Uri(exchangeWebServiceUrl)
Appointment appointment = new Appointment(service);
appointment.Subject = "Testing";
appointment.Start = DateTime.Now;
appointment.End = appointment.Start.AddHours
appointment.Save();
}
}
}