Check if Public Folder Exists

W

Wouter

Hi,

I'm using the code below to check if a public folder "HelpDesk"
exists. If so, move a copy of the current mailitem to this folder and
then send the message. If not, just send it. In my search at Google
Groups I found posts mentioning some 'FileSystemObject', which I tried
getting to work. Needless to say it didn't work (the folder checking
part, that is - the copying and moving works fine) so what am I doing
wrong here?

TIA,
Wouter

************************************************************

Sub ButtonSend_Click()
On Error Resume Next
Dim objNameSpace
Dim objFSO
Dim MyFolder1, MyFolder2, MyFolder3
Dim myCopiedItem

Set objNamespace = Application.GetNamespace("MAPI")
Set MyFolder1 = objNamespace.Folders("Public Folders")
Set MyFolder2 = MyFolder1.Folders("All Public Folders")
Set MyFolder3 = MyFolder2.Folders("HelpDesk")

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(MyFolder3) Then
Set myCopiedItem = Item.Copy
myCopiedItem.Move MyFolder3
End If

Item.Send

End Sub
 
S

Sue Mosher [MVP-Outlook]

FileSystemObject is for file folders, not Outlook folders. Use this instead:

If Not MyFolder3 Is Nothing Then
' you know you have the folder
End If
 

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