hey guys
Ive had a quick search around and couldnt find anything that was remotely close to what I need.
Ive written the following code to run as a macro to send select emails into a folder when the button is clicked on. However because this is my default mailbox in mt outlook I keep getting the error message I built in. How do I get outlook to look at a specific name mailbox instead of the default one?
cheers guys
Ive had a quick search around and couldnt find anything that was remotely close to what I need.
Ive written the following code to run as a macro to send select emails into a folder when the button is clicked on. However because this is my default mailbox in mt outlook I keep getting the error message I built in. How do I get outlook to look at a specific name mailbox instead of the default one?
Code:
Sub ActionedNFA()
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders("1 Action Taken - no further action")
'Assume this is a mail folder
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is selected
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
cheers guys