Bonjour,

Dans le cadre d'un projet d'entreprise, j'ai besoin de pouvoir récupérer les messages de certaines boites mails en passant par le web service de notre serveur Exchange. Celà fonctionne avec ma boite personnelle, mais pas avec certaines boîtes prévues pour nos clients.

j'obtiens cette erreur : The response received from the service didn't contain valid XML.

mon code est le suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Exchange.WebServices;
using Microsoft.Exchange.WebServices.Data;
using System.Net;
using System.Diagnostics;
 
namespace TachesPlanifiees
{
    class EcouteInstructionMail
    {
        public void run()
        {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
            service.Credentials = new NetworkCredential(@"xxx", @"xxx","xxx");
            service.Url = new Uri("https://www.myserver.fr/ews/exchange.asmx");
            PropertySet itemPropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
            ItemView view = new ItemView(int.MaxValue);
            view.PropertySet = itemPropertySet;
            SearchFilter filter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived, DateTime.Now.AddMinutes(-120));
            FindItemsResults<Item> results = service.FindItems(WellKnownFolderName.Inbox, filter, view);
            foreach (EmailMessage item in results)
            {
                Debug.WriteLine(item.Subject);
            }
        }
        static bool RedirectionCallback(string url)
        {
            // Return true if the URL is an HTTPS URL.
            return url.ToLower().StartsWith("https://");
        }
    }
}
merci de votre attention