Hossam Abdel Wahab

Hi all

I serach for any thing help on this issue but I get Nothing anyone can help me Plesae

thanks & regards




Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

ahlam.eissa

This will work on Office 2003
You will just have to "Add Reference" to "Microsoft Outlook 11.0 Object Library" (or any other version depending on the version of Office on your machine)

It is not working on Office 2007! (12 Object Library)


//Create Outlook Application
MyOutlook.Application oApp = new MyOutlook.Application();
oApp.AnswerWizard.ClearFileList();
oApp.ActiveWindow();

MyOutlook.MAPIFolder oContacts = (MyOutlook.MAPIFolder)oApp.Application.ActiveExplorer().Session.GetDefaultFolder(MyOutlook.OlDefaultFolders.olFolderContacts);


foreach (MyOutlook.ContactItem oContact in oContacts.Items)
{

Response.Write(oContact.Email1DisplayName);
}





Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

Hosam Abdel Wahab

Hi

i using your code as you type but Converted to VB.net as below

Dim oApp As New MyOutlook.Application

oApp.AnswerWizard.ClearFileList()

oApp.ActiveWindow()

Dim oContacts As MyOutlook.MAPIFolder = DirectCast(oApp.Application.ActiveExplorer().Session.GetDefaultFolder(MyOutlook.OlDefaultFolders.olFolderContacts), MyOutlook.MAPIFolder)

For Each oContact As MyOutlook.ContactItem In oContacts.Items

Response.Write(oContact.Email1DisplayName)

Next

I trace the code but get looping

did U have any suggest

thanks






Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

ahlam.eissa

check

oContacts.Items.Count

does it contain the number of contacts in your outlook





Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

Hosam Abdel Wahab

I get this error after execution

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 36:     oApp.ActiveWindow()
Line 37: 
Line 38:     Dim oContacts As MyOutlook.MAPIFolder = DirectCast(oApp.Application.ActiveExplorer().Session.GetDefaultFolder(MyOutlook.OlDefaultFolders.olFolderContacts), MyOutlook.MAPIFolder)
Line 39: 
Line 40: 






Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

ahlam.eissa

Did you add reference to "Microsoft Outlook 11.0 Object Library"

and are using Office 2003

Best Regards





Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

Hosam Abdel Wahab

I iused the 2 Ways

-- Using "Microsoft Outlook 12.0 Object Library", office 2007

Error I get

Opertion Faild

Using "Microsoft Outlook 11.0 Object Library", office 2003

error i get

Cast not valid but go and read all contact error apear when start Write

response.warite(oContact.firstname)

thanks






Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

ahmedilyas

I believe that the suggested solution may not work for the client as the code would be executing on the server therefore it will only ever work on the server. You need some form of clientside coding to do this but this may also involve alot of security issues, such as the user disabling scripting on their browser or perhaps require some runtime files installed on their system in order to interact with the operation.




Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

Hosam Abdel Wahab

when start looping in the contact item and write values to db i get this error , but i read only the first one

Specified cast is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:

Line 47: 
Line 48:     'Try
Line 49:     For Each oContact As MyOutlook.ContactItem In oContacts.Items
Line 50:       Dim FN As String = oContact.Email1DisplayName
Line 51:       Response.Write(FN)





Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

ahlam.eissa

finally it worked!!

did you use Office 2003

try to remove the groups... only keep the contacts and try again!





Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

ahlam.eissa

yes..this code will only access your outlook..or outllooks in the same domain

If you want to make it access the client PCs then you better make it win app/service.





Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

Hosam Abdel Wahab

yeah , finally

your suggest is good kindly can you tell how can i strat to import contacts from pc(s)






Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

ahlam.eissa

is it a web applictaion

will it be used in a LAN or over the net





Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

Hosam Abdel Wahab

yaeh web app. and it will be over lan




Re: .NET Framework Data Access and Storage Import and Export Outlook Contacts To SQL db Via asp.net web application

Hosam Abdel Wahab

I faceing Strange problem , after i can import from outlook and i tested many times last time when import .
i get error
Access is denied

i remove the reference and add again , when i build i get

Namespace or type 'Outlook' for the Imports 'Microsoft.Office.Interop.Outlook' cannot be found.
and all Syntax on this Namespace
Sad

any sugeest ,