title: Creating appointment with c# using EWS
body: <p>I want to create an program which makes it able to create an appointment in someone else's outlook calendar. for example : If someone asks 5 days free at his boss, the boss needs to be able to approve it and immediately make it visible in the person's outlook calendar. I tried making a code with EWS but i always get this error:<a href="https://i.stack.imgur.com/6pSfY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6pSfY.png" alt="enter image description here"></a>
  <em>An unhandled exception of type 'Microsoft.Exchange.WebServices.Data.AutodiscoverLocalException' occurred in Microsoft.Exchange.WebServices.dll
  Additional information: Autodiscover blocked a potentially insecure redirection to</em> </p>
  
  <p>here is my code:</p>
  
  <pre><code>    using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows.Forms;
      using Microsoft.Exchange.WebServices.Data;
  
  namespace exchangetest
  {
  public partial class Test1 : Form
  {
  
      public Test1()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          ExchangeService service = new ExchangeService();
          service.UseDefaultCredentials = true;
          service.Credentials = new WebCredentials("username@domain.com", "password");
          service.AutodiscoverUrl("username@domain.com");
          Appointment appointment = new Appointment(service);
  
          // Set the properties on the appointment object to create the appointment.
          appointment.Subject = "Tennis lesson";
          appointment.Body = "Focus on backhand this week.";
          appointment.Start = DateTime.Now.AddDays(2);
          appointment.End = appointment.Start.AddHours(1);
          appointment.Location = "Tennis club";
          appointment.ReminderDueBy = DateTime.Now;
  
          // Save the appointment to your calendar.
          appointment.Save(SendInvitationsMode.SendToNone);
  
          // Verify that the appointment was created by using the appointment's item ID.
          Item item = Item.Bind(service, appointment.Id, new PropertySet(ItemSchema.Subject));
      }
  }
  }
  </code></pre>
  
  <p>I really hope someone can help me with this.</p>