Send appointments to a list of Recipients (exchange 2007) via c#

To use this code, you need to install http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1 , this will create a dll, that you need to import to the project


try
 {
 // TODO: Write implementation for action

 ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
 service.Credentials = new NetworkCredential(ssAuthentication.ssSTAuthentication.ssUsername, ssAuthentication.ssSTAuthentication.ssPassword, ssAuthentication.ssSTAuthentication.ssDomain);
 service.Url = new Uri(ssAuthentication.ssSTAuthentication.ssServiceUrl);

 Appointment appointment = new Appointment(service);
 appointment.Subject = ssSubject;
 appointment.Body = ssDescription;
 appointment.Start = ssStartDate;
 appointment.End = ssEndDate;
 appointment.Location = ssLocation;

 for (int i = 0; i < ssRecipients.Length; i++)
 {
 appointment.RequiredAttendees.Add(ssRecipients[i].ssSTListOfEmails.ssEmail);
 }

 appointment.Save(SendInvitationsMode.SendOnlyToAll);
 }
 catch (Exception e)
 {
 ssErrors = "The error is: " + e.ToString();
 }

Read More... Send appointments to a list of Recipients (exchange 2007) via c#

Send email (exchange 2007) via c#

To use this code, you need to install http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1 , this will create a dll, that you need to import to the project

//connection to ExchangeServer
 try
 {
  ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

  service.Credentials = new NetworkCredential(ssAuthentication.ssSTAuthentication.ssUsername, ssAuthentication.ssSTAuthentication.ssPassword, ssAuthentication.ssSTAuthentication.ssDomain);

  
  service.Url = new Uri(ssAuthentication.ssSTAuthentication.ssServiceUrl);

  // Create an e-mail message and identify the Exchange service.
  EmailMessage message = new EmailMessage(service);

  // Add properties to the e-mail message.
  message.From = ssSender;
  message.Subject = ssEmailSubject;
  message.Body = ssEmailDescription;
  for (int i = 0; i < ssRecipient.Length; i++)
  {
  message.ToRecipients.Add(ssRecipient[i].ssSTListOfEmails.ssEmail);
  }

  // Send the e-mail message and save a copy.
  message.Send();
 }
 catch (Exception e)
 {
 ssErrors = "The error is: " + e.ToString();
 }

Read More... Send email (exchange 2007) via c#

Access to email exchange from c#

To use this code, you need to installhttp://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1 , this will create a dll, that you need to import to the project

 ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

 service.Credentials = new NetworkCredential(user, password, domain);

 service.Url = new Uri("https://domain/EWS/Exchange.asmx");

 Mailbox mb = new Mailbox(email_to_access);
 FolderId fid1 = new FolderId(WellKnownFolderName.Inbox, mb);

 //reads the emails
 FindItemsResults <Item> findResults = service.FindItems(fid1, new ItemView(50));


 foreach (Item item in findResults.Items)
 {
  item.Load();
  EmailMessage m = (EmailMessage)item;
  if (!m.IsRead)
  {
   //Set Isread.
   m.IsRead = true;
   m.Update(ConflictResolutionMode.AutoResolve);
  }
 }

Read More... Access to email exchange from c#

Access to a appoitment from the Exchange calendar in c#

To use this code, you need to installhttp://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1 , this will create a dll, that you need to import to the project

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

 service.Credentials = new NetworkCredential(user, password, domain);

 service.Url = new Uri("https:/domain/EWS/Exchange.asmx");

 Mailbox mb = new Mailbox(email_to_access);

 DateTime startDate = new DateTime(2010, 1, 1);
 DateTime endDate = new DateTime(2011, 1, 31);
 CalendarView calView = new CalendarView(startDate, endDate);
 calView.PropertySet = new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.IsRecurring, AppointmentSchema.AppointmentType);

 FindItemsResults <Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, calView);

 foreach (Appointment appt in findResults.Items)
 {
  if (appt.AppointmentType == AppointmentType.Occurrence)
  {
  // Calendar item is an occurrence in a recurring series.
  }
  else if (appt.AppointmentType == AppointmentType.Exception)
  {
  // Calendar item is an exception in a recurring series.
  }
 }
 
Read More... Access to a appoitment from the Exchange calendar in c#