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.
Author |
Topic |
notsosuper
Posting Yak Master
190 Posts |
Posted - 2005-08-26 : 11:40:54
|
I finally get my code work and transfer my data to public folders, but because this data in ms access table will be new every night, I need to be able to update, I have looked some post that entry id is helpful, where in my code I can put entryid then update that id later? OR how can I delete all items in my contact folder everynight before execute this code, this way I can get updated records too..Please advice. 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") oCt = Nothing While rs.Read 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 End Sub |
|
|
|
|