Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET + Outlook 2003 Contact Information 2

Status
Not open for further replies.

Peace2u

Programmer
Mar 5, 2006
9
DE
Hi everybody,

I am desparate, I can't get this code to work from an ASP.NET webpage.
Problem is when I try to retrieve contact information and I get to
MyDataRow("Tel.") = MyContact.BusinessTelephoneNumber, My App just hangs.
I think it is because normally a dialog box would open up and say that an external program is trying to "connect" to outlook and if I want to allow it.
Does anybody know a workaround?

Thank you in advance,

MyOutlook = New Outlook.Application
MyNamespace = MyOutlook.GetNamespace("MAPI")
Dim MyOutlookProcess() As Process
MyOutlookProcess = Process.GetProcessesByName("OUTLOOK")
If MyOutlookProcess.Length > 0 Then
MyNamespace.Logon(Nothing, Nothing, True, False)
Else
MyNamespace.Logon(Nothing, Nothing, True, True)
End If
MyContactFolder = MyNamespace.GetFolderFromID(GlobalSettings.SelectedContactFolder)

MyContactDataTable = New DataTable("Kontakten")
MyContactDataTable.Columns.Add(New DataColumn("Select", System.Type.GetType("System.Boolean")))
MyContactDataTable.Columns("Select").AllowDBNull = False
MyContactDataTable.Columns.Add(New DataColumn("Objekt-Nr."))
MyContactDataTable.Columns.Add(New DataColumn("KundenTyp"))
MyContactDataTable.Columns.Add(New DataColumn("Firma"))
MyContactDataTable.Columns.Add(New DataColumn("Strasse"))
MyContactDataTable.Columns.Add(New DataColumn("PLZ"))
MyContactDataTable.Columns.Add(New DataColumn("Ort"))
MyContactDataTable.Columns.Add(New DataColumn("Name"))
MyContactDataTable.Columns.Add(New DataColumn("Geburtstag"))
MyContactDataTable.Columns.Add(New DataColumn("Vorname"))
MyContactDataTable.Columns.Add(New DataColumn("Abteilung"))
MyContactDataTable.Columns.Add(New DataColumn("Tel."))
MyContactDataTable.Columns.Add(New DataColumn("Fax"))
MyContactDataTable.Columns.Add(New DataColumn("Mobil"))
MyContactDataTable.Columns.Add(New DataColumn("Mail"))
MyContactDataTable.Columns.Add(New DataColumn("Internet"))
MyContactDataTable.Columns.Add(New DataColumn("Bemerkungen"))
MyContactDataTable.Columns.Add(New DataColumn("InDB"))

If SelectedInDB = "Nein" Then
SelectedInDB = "N"
Else
SelectedInDB = "J"
End If
For Each MyContact In MyContactFolder.Items
Dim ObjectID As String = ""
Dim InDB As String
Dim KundenTyp As String
Dim PropertyNumber As String
Try
If Not IsNothing(MyContact.ItemProperties("ID").Value) Then
ObjectID = MyContact.ItemProperties("ID").Value
Else
ObjectID = i & "T"
End If
Catch ex As Exception
ObjectID = i & "T"
End Try
Try
If Not IsNothing(MyContact.ItemProperties("InDB").Value) Then
InDB = MyContact.ItemProperties("InDB").Value
Else
InDB = "N"
End If
Catch ex As Exception
InDB = "N"
End Try
Try
If Not IsNothing(MyContact.ItemProperties("KundenTyp").Value) Then
KundenTyp = MyContact.ItemProperties("KundenTyp").Value
Else
KundenTyp = ""
End If
Catch ex As Exception
KundenTyp = ""
End Try
If SelectedKundenTyp = "" Or KundenTyp = SelectedKundenTyp Then
If InDB = SelectedInDB Then
Dim MyDataRow As DataRow
MyDataRow = MyContactDataTable.NewRow
MyDataRow("Select") = False
MyDataRow("Objekt-Nr.") = ObjectID
If KundenTyp.Trim = "" Then
MyDataRow("KundenTyp") = ""
Else
MyDataRow("KundenTyp") = DBKundenTyp.GetKundenTypBeschreibung(KundenTyp)
End If
MyDataRow("Firma") = MyContact.CompanyName
MyDataRow("Strasse") = MyContact.BusinessAddressStreet
MyDataRow("PLZ") = MyContact.BusinessAddressPostalCode
MyDataRow("Ort") = MyContact.BusinessAddressCity
MyDataRow("Name") = MyContact.LastName
MyDataRow("Geburtstag") = MyContact.Birthday
MyDataRow("Vorname") = MyContact.FirstName
MyDataRow("Abteilung") = MyContact.Department
Here it just hangs and nothing happens anymore --> MyDataRow("Tel.") = MyContact.BusinessTelephoneNumber
MyDataRow("Mobil") = MyContact.MobileTelephoneNumber
MyDataRow("Fax") = MyContact.BusinessFaxNumber
MyDataRow("Mail") = MyContact.Email1Address
MyDataRow("Internet") = MyContact.BusinessHomePage
MyDataRow("Bemerkungen") = MyContact.Body
MyDataRow("InDB") = InDB
MyContactDataTable.Rows.Add(MyDataRow)
End If
End If
i += 1
Next
datagrid1.DataSource = MyContactDataTable
datagrid1.DataBind()
Catch ex As Exception
MyNamespace.Logoff()
MyOutlook.Quit()
Exit Sub
Finally
MyNamespace.Logoff()
MyOutlook.Quit()
datagrid1.Visible = True
End Try

/Peace2u
 
that is a great new feature since office 2000 sp1 i think, which threw a wrench in many of my Access database emailings. There is a couple of work arounds, third party software, one called PTFB ( and
yet those would have to be installed on each machine.

If you use outlook in an ms exchange environment, there is a outlook security settings global control you can implement. (
 
Thank you very much.

You saved my life and my nerves :) I voted for you as TipMaster :) You really are the greatest. Thanks, thanks, thanks :)

/Peace2u
 
I would advise looking up webdav and trying to query the exchange server that way.

Christiaan Baes
Belgium

"My new site" - Me
 
Hi Chrissie1,

yes I thought of that, but that was the way I did NOT want to use :) It's a head breaker using webDav. Can u send me a sample code, becuase I really don't understand how it works...
If it doesn't work with the control I will have to do it that way.
Thanks again, from 6 forums you where the only 2 that answered.

Thanks a lot.

/Peace2u my friends
 
No need to reinvent the wheel look here


and here


and if you still feel lucky, here


The server needs to have OWA installed to make webdav work. This is a little detail they always seem to forget to mention.

Christiaan Baes
Belgium

"My new site" - Me
 
Thanks a lot,

That was a great help.

You've got your vote 2 :)

/Peace2u my friend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top