11

I get an error when I try to create an appointment:

The expected XML node type was XmlDeclaration, but the actual type is Element.

This Exception occurs when I call AutodiscoverUrl.
I created a web service to do this.

[webMethod]
CreateAppointment()
{
    var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1)
    {
        Credentials = new WebCredentials("myAcount@gmail.com", "mypassowrd")
    };

    service.AutodiscoverUrl("myAcount@gmail.com");

    //----------------------------------------------------------------------
    var app = new Appointment(service)
    {
        Subject = "Meet George",
        Body = "You need to meet George",
        Location = "1st Floor Boardroom",
        Start = DateTime.Now.AddHours(2),
        End = DateTime.Now.AddHours(3),
        IsReminderSet = true,
        ReminderMinutesBeforeStart = 15
    };
    app.RequiredAttendees.Add(new Attendee("any@gmail.com"));
    app.Save(SendInvitationsMode.SendToAllAndSaveCopy);
}
  • 1
    I put a bounty on this. This works great for some users, but not for others. I have an exception with the email address. I was able to send TO the email address. – Jess Jun 18 '15 at 16:43
  • It does not have to do with the email address. I just ran this line of code with the email address in question and it worked fine: `_exchangeService = new ExchangeService(ExchangeVersion.Exchange2013_SP1); _exchangeService.AutodiscoverUrl(_sender);` – Jess Jun 18 '15 at 16:51
  • @Jess: Can you check whether the EWS virtual directory is configured to use ASP.NET 1.1 in IIS? If so, try changing it to ASP.NET 2.0. – Douglas Jun 19 '15 at 16:08
  • Have you tried using Fiddler to see what goes to and from the AWS web service? Do it for an email address that works and one that doesn't, and see if there's any major differences in the data. – Daz Jun 24 '15 at 15:11

2 Answers2

0

Some potential answers.

  1. Passing in the wrong url or domain.
  2. Passing in a bad email address.
  3. Rebuilding the Windows Profile can sometimes help. (Warning: have an IT Admin do this). And it might be overkill.
  4. A user could have an old, bad, or multiple outlook profiles set up. The email server name could be bad in the outlook profile. (See Control Panel > Mail)
Jess
  • 23,901
  • 21
  • 124
  • 145
0

Autodiscover depends on two things:

  1. DNS entries that point from the users mail domain to the Autodiscover data on the Exchange server. Typically you would have a DNS entry with the name autodiscover.domain.com, but there's more than one way of setting this up for different versions of Exchange. If the correct DNS entry doesn't exist, auto-discovery will fail.

  2. Autodiscover data hosted on the Exchange server (I believe it's an XML file) and accessed over HTTP. If this isn't accessible (perhaps it's behind a firewall) then auto-discovery will fail.

Check the appropriate DNS entries and autodiscover information is accessible to your client.

Daz
  • 2,833
  • 2
  • 23
  • 30