Add contact to outlook 2003 code / strange error message
- From: "ARC" <PCESoft@xxxxxxxxxxxxxxx>
- Date: Sat, 8 Mar 2008 23:52:33 -0600
Hello all,
I now have code working that will add a contact to outlook 2003, however, Microsoft Outlook is giving the following warning message:
"The text or attachments in the current contact's message body will not be copied to the existing contact. If you with to keep the new message body information, select Cancel and make a coyp of it. If you don't need the new information, select OK." with an ok/cancel option.
Anyeone seen this before? Many thanks,
Andy
My save to outlook 2003 code is as follows:
------------------------------------------------
Public Sub saveoutlookcont()
On Error GoTo ErrRtn
' This code is based in Microsoft Access.
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("_ContactsOutlook")
' Set up Outlook objects.
Dim ol As Object 'New Outlook.Application
Dim olns As Object 'Outlook.Namespace
Dim cf As Object 'Outlook.MAPIFolder
Dim c As Object 'Outlook.ContactItem
Dim objItems As Object 'Outlook.Items
Dim Prop As Object 'Outlook.UserProperty
Dim iNumContacts As Long, i As Long
Set ol = CreateObject("Outlook.Application")
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderContacts) 'olFolderContacts declared as 10 in declarations section
'Set objItems = cf.Items
'Set itm = itms.Add(strContactForm)
With rst
.MoveFirst
' Loop through the Microsoft Access records.
' Create a new Contact item.
Set c = ol.CreateItem(olContactItem)
'Write values from variables to fields in the new Contact item
If Not IsNull(rst![First Name]) Then c.FirstName = rst![First Name]
If Not IsNull(rst![Last Name]) Then c.LastName = rst![Last Name]
If Not IsNull(rst![Last Name]) And Not IsNull(rst![First Name]) Then
c.FullName = rst![First Name] & " " & rst![Last Name]
End If
If Not IsNull(rst!Address) Then c.BusinessAddressStreet = rst!Address
If Not IsNull(rst!City) Then c.BusinessAddressCity = rst!City
If Not IsNull(rst![State/Province]) Then c.BusinessAddressState = rst![State/Province]
If Not IsNull(rst![ZIP/Postal Code]) Then c.BusinessAddressPostalCode = rst![ZIP/Postal Code]
If Not IsNull(rst![Web Page]) Then c.webpage = rst![Web Page]
If Not IsNull(rst![E-mail Address]) Then c.Email1Address = rst![E-mail Address]
If Not IsNull(rst![Business Phone]) Then c.BusinessTelephoneNumber = rst![Business Phone]
If Not IsNull(rst![Fax Number]) Then c.BusinessFaxNumber = rst![Fax Number]
If Not IsNull(rst!Company) Then c.CompanyName = rst!Company
'rst![Mobile Phone] = c.MobilPhone
'rst![Country/Region] = c.BusinessAddressCountry 'this is proper field, but we dont' have country
c.Save
'MsgBox "Finished."
End With
MsgBox "Exported current contact to MS Outlook.", vbInformation, "Export Complete"
rst.Close
Set ol = Nothing
Exit Sub
ErrRtn:
If Err = 3270 Then 'property not found
Resume Next
Else
MsgBox "Instant Quote Pro could not import from your previous version of Outlook. The exact error that was encountered was:" & Chr(10) & Chr(10) & Err.Number & " - " & Err.Description & ", Function: ImportContactsFromOutlook", vbExclamation, "Could not import from Outlook 2003 or below"
End If
Exit Sub
End Sub
.
- Prev by Date: Re: Blob in Access
- Next by Date: How To Break Links To Linked Tables And Then Relink?
- Previous by thread: Top companies recruiting this weekend - Apply with updated resume
- Next by thread: How To Break Links To Linked Tables And Then Relink?
- Index(es):
Relevant Pages
|