Moving SPAM to a folder?

D

djtech

Hello,

If anyone can help me out with this VB code in Outlook I would greatly
help us out. This macro simply allows you to select multiple emails
and add them to your Junk Senders.txt list then it automatically
deletes the messages. What we are in search of is to simply edit it
so that rather than deleting the messages it sends them to a specific
folder called "SPAM" located under the inbox. How could we edit this
to do that?...

Private Const JUNK_SENDERS_FILE As String = _
"C:\Documents and Settings\Administrator\Application
Data\Microsoft\Outlook\Junk Senders.txt"

Public Sub MultipleJunkEMailSenders()

Dim objExplorer As Outlook.Explorer
Dim objMailItem As Outlook.MailItem
Dim intItem As Integer
Dim objFSO As Scripting.FileSystemObject
Dim objTextStream As Scripting.TextStream

Set objFSO = New Scripting.FileSystemObject

If MsgBox(Prompt:="Are you sure you want to " & _
"add all of the selected senders to your " & _
"junk e-mail sender list and then " & _
"delete all of the selected e-mail " & _
"messages? Caution: This action is not " & _
"easily reversible!", Buttons:=vbYesNo) = vbYes Then

If objFSO.FileExists(FileSpec:=JUNK_SENDERS_FILE) = False Then
Set objTextStream = objFSO.CreateTextFile _
(FileName:=JUNK_SENDERS_FILE)
Else
Set objTextStream = objFSO.OpenTextFile _
(FileName:=JUNK_SENDERS_FILE, IOMode:=ForAppending)
End If

Set objExplorer = Application.ActiveExplorer

For Each objMailItem In objExplorer.Selection

objTextStream.WriteLine Text:=objMailItem.SenderName

objMailItem.Delete

Next objMailItem

MsgBox Prompt:="All selected senders have been added " & _
"to your junk e-mail senders list and " & _
"all selected e-mails have been deleted."

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