Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 what am I doing wrong?

Author  Topic 

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-08-24 : 11:21:18
I am trying to write windows application using vb.net and get my data from ms access table to put outlook public folders, my code is not giving me error until I hit ISDBNull part start, it is giving me this error,
An unhandled exception of type 'System.MissingMemberException' occurred in microsoft.visualbasic.dll

Additional information: Public member 'ContactName' on type 'RecordsetClass' not found.

I don't know this part I need to use my variables from my access table or outlook's variable? Here my code

Public Sub getit()


Dim dao
Dim db
Dim itms
Dim itm
Dim strsql As String
Dim cn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim oApp As Outlook.Application = New Outlook.Application

Dim mynamespace As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Dim myfolder As Outlook.MAPIFolder = mynamespace.Folders("Public Folders").Folders("All Public Folders").Folders("Contacts")
Dim myitems = myfolder.Items

cn.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\contacts.mdb;User Id=;Password=;")
cn.Open()

rst = New ADODB.Recordset
rst.Open("select * from customers", cn)

mynamespace = oApp.GetNamespace("MAPI")
myfolder = mynamespace.Folders("Public Folders").Folders("All Public Folders").Folders("contacts")
myitems = myfolder.Items


Do Until rst.EOF

itm = myitems.Add("IPM.Contact.Contacts")

'Built-in Outlook properties
If IsDBNull(rst.CustomerID) = False Then itm.CustomerID = rst.CustomerID
If IsDBNull(rst.CompanyName) = False Then itm.CompanyName = rst.CompanyName
If IsDBNull(rst.ContactName) = False Then itm.FullName = rst.ContactName
If IsDBNull(rst.Address) = False Then itm.BusinessAddressStreet = rst.Address
If IsDBNull(rst.City) = False Then itm.BusinessAddressCity = rst.City
If IsDBNull(rst.Region) = False Then itm.BusinessAddressState = rst.Region
If IsDBNull(rst.PostalCode) = False Then itm.BusinessAddressPostalCode = rst.PostalCode
If IsDBNull(rst.Country) = False Then itm.BusinessAddressCountry = rst.Country
If IsDBNull(rst.Phone) = False Then itm.BusinessTelephoneNumber = rst.Phone
If IsDBNull(rst.Fax) = False Then itm.BusinessFaxNumber = rst.Fax
If IsDBNull(rst.ContactTitle) = False Then itm.JobTitle = rst.ContactTitle

'Custom Outlook properties
itm.UserProperties("Preferred") = rst.Preferred
itm.UserProperties("Discount") = rst.Discount
itm.Close(0)
rst.MoveNext()

Loop
rst.Close()
MsgBox("All contacts imported!")

End Sub
   

- Advertisement -