Error using SaveSentMessageFolder

P

Peter

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
 
S

Sue Mosher [MVP-Outlook]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top