简体   繁体   中英

Outlook Interop - MailItem.Sender is Hanging\Freeze

I use the code from the below msdn link and it is working perfectly well in my system to fetch the sender email address. However when i deploy the same code to one of our dev servers, the below line of code hangs\freeze indefinitely without any response. After tracing, i figured that if an attribute of the sender object is accessed it, hangs forever. Cache exchange mode is turned "on" the mail box and It is running in outlook 2010. I have also manually downloaded the address book from outlook but it din't help. I believe it is not a code issue. Can some one help?

https://msdn.microsoft.com/en-us/library/office/ff184624.aspx

sender.AddressEntryUserType == Outlook.OlAddressEntryUserType. olExchangeUserAddressEntry || sender.AddressEntryUserType == Outlook.OlAddressEntryUserType. olExchangeRemoteUserAddressEntry

You cannot use Outlook in a service. No Office app (Outlook included) can be used in a service.

Your choices are Extended MAPI (C++ or Delphi), Redemption (it wraps Extended MAPI and can be used from any language), or EWS .

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

A low level API on which Outlook is based supports running the code from a service. You can use any language to implement the task (C# and VB.NET). But Microsoft doesn't support such solutions/code officially. If you face with any issue you will be alone, but the managed code works as a charm.

See also EWS Managed API, EWS, and web services in Exchange .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM