M
Martin
Hi,
I've written a VB program to dump all contact info from
our helpdesk system and added these 1631 contacts to
outlook - fine.
Run it a second time and it does not update the existing
outlook contact but creates another 1631 duplicate
records.
How can I change the following to do updates instead of
inserts for existing records?
Codes is as follows:
If Not m_ContactsRS.EOF Then
MsgBox "Currently processing data with Outlook, please
wait", vbOKOnly, "CrossCompass"
Screen.MousePointer = vbHourglass
' Start Outlook.
' If it is already running, you'll use the same
instance...
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
' Logon. Doesn't hurt if you are already running and
logged on...
Dim olNs As Outlook.Namespace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon
' Create and Open a new contact.
Dim olItem As Outlook.ContactItem
' Setup Contact information...
While Not m_ContactsRS.EOF
Set olItem = olApp.CreateItem(olContactItem)
With olItem
.CompanyName = Format(m_ContactsRS.Fields
(0).Value)
.FullName = Format(m_ContactsRS.Fields(1).Value)
.CompanyMainTelephoneNumber = Format
(m_ContactsRS.Fields(2).Value)
.MobileTelephoneNumber = Format
(m_ContactsRS.Fields(3).Value)
.Email1Address = Format(m_ContactsRS.Fields
(4).Value)
End With
' Save Contact...
olItem.Save
m_ContactsRS.MoveNext
m_iRow = m_iRow + 1
Wend
m_ContactsRS.Close
olNs.Logoff
Set olNs = Nothing
Set olItem = Nothing
Set olApp = Nothing
Set m_ContactsRS = Nothing
Screen.MousePointer = vbNormal
MsgBox m_iRow & " Outlook Contacts Synched with
BridgeTrak", vbOKOnly, "CrossCompass"
Any comments appreciated
I've written a VB program to dump all contact info from
our helpdesk system and added these 1631 contacts to
outlook - fine.
Run it a second time and it does not update the existing
outlook contact but creates another 1631 duplicate
records.
How can I change the following to do updates instead of
inserts for existing records?
Codes is as follows:
If Not m_ContactsRS.EOF Then
MsgBox "Currently processing data with Outlook, please
wait", vbOKOnly, "CrossCompass"
Screen.MousePointer = vbHourglass
' Start Outlook.
' If it is already running, you'll use the same
instance...
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")
' Logon. Doesn't hurt if you are already running and
logged on...
Dim olNs As Outlook.Namespace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon
' Create and Open a new contact.
Dim olItem As Outlook.ContactItem
' Setup Contact information...
While Not m_ContactsRS.EOF
Set olItem = olApp.CreateItem(olContactItem)
With olItem
.CompanyName = Format(m_ContactsRS.Fields
(0).Value)
.FullName = Format(m_ContactsRS.Fields(1).Value)
.CompanyMainTelephoneNumber = Format
(m_ContactsRS.Fields(2).Value)
.MobileTelephoneNumber = Format
(m_ContactsRS.Fields(3).Value)
.Email1Address = Format(m_ContactsRS.Fields
(4).Value)
End With
' Save Contact...
olItem.Save
m_ContactsRS.MoveNext
m_iRow = m_iRow + 1
Wend
m_ContactsRS.Close
olNs.Logoff
Set olNs = Nothing
Set olItem = Nothing
Set olApp = Nothing
Set m_ContactsRS = Nothing
Screen.MousePointer = vbNormal
MsgBox m_iRow & " Outlook Contacts Synched with
BridgeTrak", vbOKOnly, "CrossCompass"
Any comments appreciated