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
 Development Tools
 ASP.NET
 any idea how to..

Author  Topic 

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-08-25 : 16:13:34
this starts to get my data from ms access to public folder, out of 693 records, my fist starting outlook contact folder in public f. it transfers 268 records and stops, then if I close outlook completely and open it transfers more records up to 500's, then I close and reopen then record numbers go up to 750 instead it should stop at 693. What I want happen to when I open up contact folder, all 693 records should get transfer once and it should refresh by itself too.




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 oCt As Outlook.ContactItem = oApp.CreateItem(Outlook.OlItemType.olContactItem)
Dim strsql As String

strsql = "select * from customers where id is not null "

Dim cn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\contacts.mdb;User Id=;Password=;")
Dim cmd As New OleDb.OleDbCommand(strsql, cn)

Try
cn.Open()
Dim rs As OleDb.OleDbDataReader = cmd.ExecuteReader

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



While rs.Read
oCt = Nothing
oCt = myfolder.Items.Add("IPM.Contact.contacts")

oCt.FullName = rs.Item("contactname") & ""
If IsDBNull(rs.Item("contacttitle")) = False Then oCt.JobTitle = rs.Item("contacttitle") & ""
' oCt.FileAs = rs.Item("contactname") & ""
oCt.CompanyName = rs.Item("clientname") & ""
oCt.BusinessAddressStreet = rs.Item("billingaddress1") & ""
oCt.BusinessAddressCity = rs.Item("billingcity") & ""
oCt.BusinessAddressState = rs.Item("billingstate") & ""
oCt.BusinessAddressPostalCode = rs.Item("billingzip") & ""
If IsDBNull(rs.Item("phone")) = False Then oCt.BusinessTelephoneNumber = rs.Item("phone") & ""
'If IsDBNull(rs.Item("email")) = False Then oCt.Email1Address = rs.Item("email") & ""
If IsDBNull(rs.Item("fax")) = False Then oCt.BusinessFaxNumber = rs.Item("fax") & ""
'If IsDBNull(rs.Item("Homephone")) = False Then oCt.HomeTelephoneNumber = rs.Item("homephone") & ""
'If IsDBNull(rs.Item("cell")) = False Then oCt.MobileTelephoneNumber = rs.Item("cell") & ""
''If IsDBNull(rs.Item("homeemail")) = False Then oCt.Email2Address = rs.Item("homeemail") & ""
'If IsDBNull(rs.Item("homefax")) = False Then oCt.HomeFaxNumber = rs.Item("homefax") & ""
'If IsDBNull(rs.Item("otherfax")) = False Then oCt.OtherFaxNumber = rs.Item("otherfax") & ""
'If IsDBNull(rs.Item("otherphone")) = False Then oCt.OtherTelephoneNumber = rs.Item("otherphone") & ""
oCt.Save()
oCt = Nothing
End While


rs.Close()
If rs.IsClosed = False Then rs.Close()
Catch ex As Exception
strsql = "<SCRIPT>alert('An error occurred . The message returned is - " & Replace(Replace(ex.Message, vbCrLf, ""), "'", "`") & "')</SCRIPT>"
Console.WriteLine(strsql)
Finally
If Not cn.State = ConnectionState.Closed Then cn.Close()
End Try
   

- Advertisement -