Check if Public Folder Exists

  • Thread starter Thread starter Wouter
  • Start date Start date
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
 
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
 
Back
Top