Move Mail messages to a Public Folder

G

Guest

Hi Guys,

I have an Exchange 2003 SBS Server, and I have just installed GFI ME10, and
I have enabled the Public Folders Spam filtering, What I would like to be
able to do is to have a button in Outlook that will move a message that has
been identified as Spam to the public folder which GFI Monitors.

I know I can use right click, expand public folders, open spam folder, then
click move.

I just want a button to do this in one click if at all possible.

IS this at all possible?

I cant understand why MS didnt allow us to record a Macro in Outlook.

Many Thanks,
Ryan O'Dwyer
 
G

Guest

OK, I managed to answer my own question, and i gathered together bits and
pieces from the web to do this.

Here is the code :

Public Function GetFolder(strFolderPath As String) As MAPIFolder
' folder path needs to be something like
' "Public Folders\All Public Folders\Company\Sales"
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim I As Long
On Error Resume Next

strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders() = Split(strFolderPath, "\")
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If objFolder Is Nothing Then
Exit For
End If
Next
End If

Set GetFolder = objFolder
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Function
Function GetCurrentItem() As Object
Dim objApp As Outlook.Application

Set objApp = CreateObject("Outlook.Application")
On Error Resume Next
Select Case TypeName(objApp.ActiveWindow)
Case "Explorer"
Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
Case "Inspector"
Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
Case Else
' anything else will result in an error, which is
' why we have the error handler above
End Select

Set objApp = Nothing
End Function


Public Sub mocetosave()
Set myNameSpace = Application.Session
Set myFolder = myNameSpace.GetDefaultFolder(6)
'Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myDestFolder = GetFolder("Public Folders\All Public Folders\GFI
AntiSpam Folders\This is spam email")
Set myItem = GetCurrentItem()
myItem.Move myDestFolder

End Sub

--------------
I am no VB programmer but this worked for me to move messages from Any Mail
folder in my exchange to the Public Folder.

I am sure there are things that arent supposed to be there or could be
better implemented.

Many Thanks to
* Susan Mosher (I read your newsgroup replies, and they got me on the right
track )
* http://www.outlookcode.com/codedetail.aspx?id=50
* http://www.outlookcode.com/d/code/getfolder.htm#info

I then created a button from the Macro, and it is working a Treat :)

Regards,
Ryan O'Dwyer
 

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