Microsoft.Exchange.WebServices.Data.ServiceResponseException: Connection did not succeed. Try again later

血红的双手。 提交于 2019-12-11 00:03:58

问题


I have a fairly simple email that I need to send using Exchange server. This works locally, but fails when I publish to the server. Here is my code establishing the link to the exchange server:

var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2); service.UseDefaultCredentials = true; service.AutodiscoverUrl(Config.GetGroupMailbox(),RedirectionUrlValidationCallback);

After setting the fields I am simply calling .Send() with no success.

Here is the stack trace:

Microsoft.Exchange.WebServices.Data.ServiceResponseException: SendOnly cannot be used by a user without a mailbox. Use SendAndSaveCopy and specify a folder ID in a mailbox to send an item from an account that doesn't have a mailbox. at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary() at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable1 items, FolderId parentFolderId, Nullable1 messageDisposition, Nullable1 sendInvitationsMode, ServiceErrorHandling errorHandling) at Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable1 messageDisposition, Nullable`1 sendInvitationsMode) at Microsoft.Exchange.WebServices.Data.EmailMessage.InternalSend(FolderId parentFolderId, MessageDisposition messageDisposition) at CCSSWorkflow.Models.EmailService.Send(EmailObject EmailObject, EmailSent EmailSentObject)

Thanks for the help/direction,

Sam


回答1:


I found the issue and resolved. The issue was with the user that was connecting, or attempting to connect.

I had set the service to use default setting: service.UseDefaultCredentials = true; meaning that it would try to connect as the user running the process.

When I replaced that with actual user id and password everything worked:

service.UseDefaultCredentials = false;
service.Credentials = new WebCredentials(Config.GetEmailConnectionUserID(),
                                         Config.GetEmailConnectionPassword());


来源:https://stackoverflow.com/questions/33767176/microsoft-exchange-webservices-data-serviceresponseexception-connection-did-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!