Question

I've built a web app that use Redemption to read a mailbox, let's call it "custom@domain.com". It works fine using localhost but when I deploy it I get this exception.

Error System.Runtime.InteropServices.COMException (0x80004005): Creating an instance of the COM component with CLSID {29AB7A12-B531-450E-8F7A-EA94C2F3C05F} from the IClassFactory failed due to the following error: 80004005. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic)

I'm guessing my server is using its network user as the default user to logon to the mailbox, instead of the current windows NT user accessing the web app. How do I get the server or my RDO code to use the current NT user using the app with RDO?

I have installed MAPI Extension on my server and registered the dll in the registry.

My RDO code looks like this

 RDOSession Session = null;
        rdoDefaultFolders olFolderInbox = rdoDefaultFolders.olFolderInbox;

        Session = new RDOSession();//this throws the exception above
        Session.LogonExchangeMailbox("username@domain.com", outLookServer);  
         objFolder = Session.GetDefaultFolder(olFolderInbox);
Was it helpful?

Solution

The Nightmare (Or not so recommended) Solution The problem I believe was the bitness of the application as Dmitry pointed out. However the problem with converting your apps to 32bit or 64 bit is the inevitable and horrible chain reaction of converting EVERY project in your solution to use the same bitness so that the application can use the MAPI of the same bit. If you have other apps that use the same libraries and projects then those may also break so this is easier said than done. In fact I tried it and it broke the project in so many ways...decided it wasn't worth it.

The Best Solution

For Exchange Server 2007_SP1 and above we have a handy WebService called Exchange Web Services MAPI that does the same thing as Redemption...maybe not as much but it does the trick for your everyday outlook needs. Read the Guide in the download for better information.

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13480

This is the best solution for me because it does not require any app to specify a bit, it does not require any special instructions and there are no loose ends. A simple DLL that does exactly what you need with authentication and even impersonation. And who doesn't like webservices?

Sample Code

using ExWs = Microsoft.Exchange.WebServices.Data; 

 ExWs.ExchangeService service = new 
                   ExWs.ExchangeService(ExWs.ExchangeVersion.Exchange2007_SP1);
                    service.Credentials = new   
                   ExWs.WebCredentials("username", "password", "domain");
                    service.AutodiscoverUrl("name@company.com");

Tutorials Again read the Guide or google it.
other examples http://omegacoder.com/?p=454
Download attachment from Exchange using Exchange Web Services

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top