drivetheory
Member
- Outlook version
- Outlook 2013 64 bit
- Email Account
- IMAP
Idk why this isn't working...
it's basically the code verbatim from here:
But for whatever reason i can't test it in the VBA editor window, and when I add it to a rule it still doesn't do anything.
what am I doing wrong?
Code:
Sub MoveMail(Item As Outlook.mailItem)
If Item.Attachments.Count > 0 Then
Dim attCount As Long
Dim strFile As String
Dim sFileType As String
attCount = Item.Attachments.Count
For i = attCount To 1 Step -1
strFile = Item.Attachments.Item(i).FileName
sFileType = LCase$(Right$(strFile, 4))
Select Case sFileType
Case ".doc"
' do something if the file types are found
' this code moves the message
Item.Move (Session.GetDefaultFolder(olFolderInbox).Folders("BADSTUFF"))
' stop checking if a match is found and exit sub
GoTo endsub
End Select
Next i
End If
endsub:
Set Item = Nothing
End Sub
it's basically the code verbatim from here:
Use VBA to move messages with attachments
Use a run a script rule or an ItemAdd macro to look for messages with attachments. When the attachment is a specific file type, do something with the message.
www.slipstick.com
But for whatever reason i can't test it in the VBA editor window, and when I add it to a rule it still doesn't do anything.
what am I doing wrong?