I have an email account on a remote server.
I created an application that utilizes outlook interop api to search for an email with specific subject than extract an attachment from it and save it to a directory.
Everything is fine when I run that application manually.
But when I create a scheduled task for this application, I get
Stack:
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(System.RuntimeType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(System.RuntimeType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(System.RuntimeType, System.Object[], Boolean)
at System.RuntimeTypeHandle.CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef)
at System.RuntimeType.CreateInstanceSlow(Boolean, Boolean, Boolean)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean, Boolean, Boolean, Boolean)
at System.Activator.CreateInstance(System.Type, Boolean)
at PocketDataFromEmail.EmailManager..ctor()
at MyApp.Program.Main(System.String[])
It is said that outlook is not suitable for that kind of scenarios:
Is Interop.Outlook multithreaded?
Any ideas on how to check the inbox of an exchange account and extract attachments without using outlook interop api?
Thanks.
Would Exchange Web Services be an option?
http://msdn.microsoft.com/en-us/library/dd877045.aspx
There is also MAPI, though it is older technology, and I recall it wasn’t that fun to use:
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e17e7f31-079a-43a9-bff2-0a110307611e&displaylang=en