views:

93

answers:

3

Hi, I have created a we application for managing the contacts. I want to save the selected contact to current user's outlook contact list. how to do this? I am using asp.net + c#.net. please guide me.

Edited :

I have done this by following this link.

http://www.c-sharpcorner.com/uploadfile/rambab/outlookintegration10282006032802am/outlookintegration.aspx?login=true&user=lalitcdhake

its a great and easy to understand windows application for the same. I used Class library. It is running fine locally. but s I deploy my application in IIS and access it from outside network it showing dialog box with message :

" an unhandled win32 exception occurred in outlook.exe [876] "

What should be that ? can somebody guide me for this please?

Edit 2:

Problem is still there. While i debugging the application I am getting the exception:

Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005. + OUTLOOK

I found this is the User Account Control problem on some blog. Is it true? Or What should be the solution over this. Is any another way rather than Interop services?

+1  A: 

You cannot use the Automation API of any Office product from a web application. It doesn't work; it may violate the terms of your license. The automation APIs and the applications themselves are not tested in a multithreaded environment.

John Saunders
@Downvoter: please be an adult and tell everyone what's wrong with my answer.
John Saunders
But what technique have to use then ?? please guide........ As observe my updated question. I mentioned, it is working locally. but after deployed it is giving error.
Lalit
@Lalit: STOP USING THAT! This is exactly the kind of random behavior that occurs. Outlook is a desktop application. It is not designed to work in a multithreaded server environment. DO NOT USE IT THIS WAY.
John Saunders
Yes, john I agree with you. but what should the other way to do this? I want to save my selected contact information to the outlook of client who is currently accessing the application. what have to do. please suggest other way then.
Lalit
@Lalit: See Jonathan's answer below.
John Saunders
Hi john, I tried that dude. but wondering about there is no such option to save that vCard in outlook. how can i do this. still in trouble...
Lalit
+6  A: 

You should offer the contact as a vCard. When the user clicks on the "download" link, they will be prompted to add the vCard as a contact in Outlook.

http://en.wikipedia.org/wiki/VCard

Besides avoiding Office COM Automation, which is totally incompatible with ASP.NET, vCards are nice because everyone supports it.

Jonathan Allen
+1 for avoiding Office Automation... I've been burned too many times in the past
Brian Vander Plaats
Ok, fine but how to use vCard in my asp.net application for my requirements . what should be the steps for this?
Lalit
I read link, but could not get much .
Lalit
any updates please
Lalit
http://www.codeproject.com/KB/aspnet/vCardExport.aspx
Jonathan Allen
Thanks, Jonathan Allen.its a nice article. it is about only generate vCard ,but how to save this vCard in the outlook programmatic way? please guide .waiting here dude.
Lalit
any updates please. I got how to generate the vCard through the c# . but cn u please tell me how to save it in outlook through c# ??
Lalit
There is none. Users just click on the link and they are prompted to add the Contact.
Jonathan Allen
No,Jonathan Allen . I tried your link codeproject.com/KB/aspnet/vCardExport.aspxIt is running fine. but it not askin me to save it in the outlook contacts. please tell me have you done this before (save vcard in outlook programatically) ??
Lalit
You should just return the vCard to the user's browser with the correct content type. You may or may not need to send it as an attachment. Since Outlook is registered for that content type, it will open the contact.
John Saunders
+1  A: 
  1. Save the contacts as CVS file format
  2. Import the CVS to outlook.

How to Import a Comma Separated Value (CSV) File Into Outlook

Waleed A.K.
@Downvoter: please be an adult and tell everyone what's wrong with my answer.
Waleed A.K.
It isn't reasonable to ask a user to download a CSV file and run the import/export utility to load a single contact.
Jonathan Allen
The question was "Managing Contacts", and selected contact could be more than one, in addition CVS could work for a single or multiple Contacts.
Waleed A.K.
Personally I use Com solution in winform application because each user should have his own license, but you cannot do it in the server-side without license agreement. See the link http://support.microsoft.com/kb/257757
Waleed A.K.
ok, thanks Waleed. I will not use the interop at server side for this requiremnt. But I have problem what should then the steps contain to prepare the CSV fiel from C#. and how to save it to accessing clients outlook contacts information. Please guide.
Lalit
updates please..??
Lalit
My suggestion is to use another program that is schedule to run every period of time to access the contact database “Now you can use the Com interrupt” and import them directly to outlook. In addition add a flag for imported contacted and flag for the contact that you want to import.
Waleed A.K.
see, can i use interop in the class library project? since it will be on the server. only the aspx will use it on the fly. can this possible Waleed ?
Lalit
:) My suggestion say "another program" on the server or any machine run locally. and not aspx.
Waleed A.K.
@Lalit: Don't forget [@John Saunders] answer about the "multithreaded environment"
Waleed A.K.
ok, Waleed I agree. so you mean to say I have to write the windows service, that will fetch the contact information of configured outlook from contact database from the pop3 email server. and as I say "Add to Outlook" from my another web application, this will happens. and then it will add new contact to downloaded contact data. and will be uploads through the same windows service. Is I am right about catching you? Or is this possible, dude ?
Lalit
Kool ;) Nice JOB
Waleed A.K.