deleting emails

H

hb21l6

How can I delete all the emails in the SPAM folder?
The folders called "SPAMfighter"

The folder layout is like this ,
- MyEmails (profile name)
- deleted items (3)
- drafts
- Inbox (6)
-other folder
- Outbox (4)
- sent Items (5)
- SpamFighter
- Calendar (9)

I know I can access most of these folders using the getdefaultFolder()
method and changing the ID.

Set myNamespace = Application.GetNamespace("MAPI")
Set mFolder = objNS.GetDefaultFolder(5)



Using this loop, i still can't find the folder ID called SPAMfighter.?

Sub ListFolders()

Set myNamespace = Application.GetNamespace("MAPI")
'Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
On Error Resume Next
For i = 0 To 50
Set mFolder = myNamespace.GetDefaultFolder(i)
MsgBox mFolder.Name & " _ " & i
Next

End Sub

any idea how i can find it?

cheers
Dave
 
H

hb21l6

ahh, no worries, i've sorted it.. found a nice little sample :O)


Set inbox = Application.Session.GetDefaultFolder(olFolderInbox)
Set Root = inbox.Parent
Set myFolder = Root.Folders("SPAMfighter")

If myFolder.Name = "SPAMfighter" Then
For Each Item In myFolder.Items
Item.Delete
Next
End If

End Sub
 

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