public static ExchangeService GetExchangeService()
{
DataTable dt = ReadConfigXml("~/app_data/email.xml");
string userName = ReadConfigValue(dt, "ews_username").ToString();
string password = ReadConfigValue(dt, "ews_password").ToString();
string domain = ReadConfigValue(dt, "ews_domain").ToString();
string uriString = ReadConfigValue(dt, "ews_exchangewebservice").ToString();
string str5 = ReadConfigValue(dt, "ews_exchangeversion").ToString();
ReadConfigValue(dt, "ews_mail").ToString();
ExchangeService service = new ExchangeService();
if (str5 != "")
{
switch (str5)
{
case "Exchange2007_SP1":
service = new ExchangeService(0);
goto Label_0169; case "Exchange2010":
service = new ExchangeService(1);
goto Label_0169; case "Exchange2010_SP1":
service = new ExchangeService(2);
goto Label_0169; case "Exchange2010_SP2":
service = new ExchangeService(3);
goto Label_0169; case "Exchange2013":
service = new ExchangeService(4);
goto Label_0169; case "Exchange2013_SP1":
service = new ExchangeService(5);
goto Label_0169;
}
service = new ExchangeService();
}
Label_0169:
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(Helper.RemoteCertificateValidate);
if (domain == "")
{
service.set_Credentials((ExchangeCredentials) new NetworkCredential(userName, password));
}
else
{
service.set_Credentials((ExchangeCredentials) new NetworkCredential(userName, password, domain));
}
service.set_Url(new Uri(uriString));
service.set_Timeout(0x30d40);
return service;
}提示错误为:
{
DataTable dt = ReadConfigXml("~/app_data/email.xml");
string userName = ReadConfigValue(dt, "ews_username").ToString();
string password = ReadConfigValue(dt, "ews_password").ToString();
string domain = ReadConfigValue(dt, "ews_domain").ToString();
string uriString = ReadConfigValue(dt, "ews_exchangewebservice").ToString();
string str5 = ReadConfigValue(dt, "ews_exchangeversion").ToString();
ReadConfigValue(dt, "ews_mail").ToString();
ExchangeService service = new ExchangeService();
if (str5 != "")
{
switch (str5)
{
case "Exchange2007_SP1":
service = new ExchangeService(0);
goto Label_0169; case "Exchange2010":
service = new ExchangeService(1);
goto Label_0169; case "Exchange2010_SP1":
service = new ExchangeService(2);
goto Label_0169; case "Exchange2010_SP2":
service = new ExchangeService(3);
goto Label_0169; case "Exchange2013":
service = new ExchangeService(4);
goto Label_0169; case "Exchange2013_SP1":
service = new ExchangeService(5);
goto Label_0169;
}
service = new ExchangeService();
}
Label_0169:
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(Helper.RemoteCertificateValidate);
if (domain == "")
{
service.set_Credentials((ExchangeCredentials) new NetworkCredential(userName, password));
}
else
{
service.set_Credentials((ExchangeCredentials) new NetworkCredential(userName, password, domain));
}
service.set_Url(new Uri(uriString));
service.set_Timeout(0x30d40);
return service;
}提示错误为:
一般都是反编译出来的。你这个错误是new ExchangeService(4)初始化的时候有问题,
不能写整型数字int,需要具体的枚举类型
除了new ExchangeService(1)就开始出错了。
如果是编译前的写法,应该怎么写呀,网上查找的话,我应该怎么查找。
我是啥都不懂
除了new ExchangeService(1)就开始出错了。
如果是编译前的写法,应该怎么写呀,网上查找的话,我应该怎么查找。
我是啥都不懂
类ExchangeService的构造函数应该是可以传入一个枚举值的,
实例化的时候不要传入int,改成实际的枚举值