Error using SaveSentMessageFolder

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The VBA code below is executed after sending a message in outlook (OL2003).
Unfortunatelty this code will give an error as result in case the message
send is an appointment. Does anyone know how i can prevent this error?

Thx.

Peter

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Exit Sub
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If TypeName(objFolder) = "Nothing" Then
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderDeletedItems)
End If
Item.SaveSentMessageFolder = objFolder (this line causes the error)
Set objFolder = Nothing
Set objNS = Nothing
End Sub
 
You can use the the Class property of Item to determine what type of item it is, before you apply methods or properties specific only to a particular type of item.

Or just add an On Error Resume Next statement to ignore the error.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top