A
Andrew Cushen
Hi all-
I'm back again! ;-)
I have some code I got from Gordon Padwick and Ken
Slovak's book, "Programming Microsoft Outlook 2000", that
changes the message class of an item so that you can use a
form you've created for existing Task items.
I have adapted it for changing Contact items to use a
Contact form I've created, called "SendFax".
I'm using Outlook 2000, BTW.
The code runs, but it always fails to change 4 or 5
contacts out of a few hundred. When I write the Err.Number
& .Description to the screen at the end of processing it
tells me "Run-time Error '13': Type mismatch". Yet it
correctly processes all the other contacts!
The code follows:
******************[ CODE BEGIN ]************************
Err.Clear
Dim appOl As Outlook.Application
Dim nmsNS As NameSpace
Dim strNew As String
Dim fldContacts As MAPIFolder
Dim itmItems As Items
Dim itmContact As ContactItem
strNew = "IPM.Contact.SendFax"
Set appOl = CreateObject("Outlook.Application")
Set nmsNS = appOl.GetNamespace("MAPI")
Set fldContacts = nmsNS.GetDefaultFolder
(olFolderContacts)
Set itmItems = fldContacts.Items
'Loop through items in the folder:
For Each itmContact In itmItems
With itmContact
' Message class needs to be changed - ?
If .MessageClass <> strNew Then
' Change the message class:
.MessageClass = strNew
' Save it
.Save
End If
End With
If Err.Number <> 0 Then
MsgBox Err.Number & " " & Err.Description &
vbCrLf & _
itmContact.FullNameAndCompany
End If
Next
If Err.Number = 0 Then
MsgBox "All done."
Else
MsgBox Err.Number & " " & Err.Description
End If
******************[ CODE END ]**********************
Anyone have any idea what's going on here?
Thanks,
-Andrew
I'm back again! ;-)
I have some code I got from Gordon Padwick and Ken
Slovak's book, "Programming Microsoft Outlook 2000", that
changes the message class of an item so that you can use a
form you've created for existing Task items.
I have adapted it for changing Contact items to use a
Contact form I've created, called "SendFax".
I'm using Outlook 2000, BTW.
The code runs, but it always fails to change 4 or 5
contacts out of a few hundred. When I write the Err.Number
& .Description to the screen at the end of processing it
tells me "Run-time Error '13': Type mismatch". Yet it
correctly processes all the other contacts!
The code follows:
******************[ CODE BEGIN ]************************
Err.Clear
Dim appOl As Outlook.Application
Dim nmsNS As NameSpace
Dim strNew As String
Dim fldContacts As MAPIFolder
Dim itmItems As Items
Dim itmContact As ContactItem
strNew = "IPM.Contact.SendFax"
Set appOl = CreateObject("Outlook.Application")
Set nmsNS = appOl.GetNamespace("MAPI")
Set fldContacts = nmsNS.GetDefaultFolder
(olFolderContacts)
Set itmItems = fldContacts.Items
'Loop through items in the folder:
For Each itmContact In itmItems
With itmContact
' Message class needs to be changed - ?
If .MessageClass <> strNew Then
' Change the message class:
.MessageClass = strNew
' Save it
.Save
End If
End With
If Err.Number <> 0 Then
MsgBox Err.Number & " " & Err.Description &
vbCrLf & _
itmContact.FullNameAndCompany
End If
Next
If Err.Number = 0 Then
MsgBox "All done."
Else
MsgBox Err.Number & " " & Err.Description
End If
******************[ CODE END ]**********************
Anyone have any idea what's going on here?
Thanks,
-Andrew