2002 - How to delete PIF & EXE files?

M

Mike Hudson

-----Original Message-----
Using Outlook 2002 on 98SE machine.

Question: I want to have Outlook 2002 "delete" any email that arrives
with the PIF or EXE attachment.

Thank you.
.

It is possible!
If you search the newgroup for removing attachment
security you will find a registry fix, that you could use
the other way round :)
 
M

Mike Hudson

I wasn't trying to be cryptic.

You could use VB Script to delete the attachments!!

You will need to capture the newmail event, the use the
item.attachments object to check the extension

I don't really have the time to write the vb code for
you..

I am sure you will find all the info you need in the help
file of the Visual Basic Script editor.

If not, let me know and I will see what I can do..
 
G

Guest

Here is something I have 'thrown' together!

This will throw up an error if a receipt is in the
mailbox.

Dim objInbox As MAPIFolder
Dim olitems As Items
Dim objMailItem As MailItem

Private Sub Application_NewMail()
Set objInbox = Outlook.Session.GetDefaultFolder
(olFolderInbox)
Set objitems = objInbox.Items

For Each objMailItem In objitems

For i = 1 To objMailItem.Attachments.Count
If InStr(1, objMailItem.Attachments.Item
(i).filename, ".bat") Or InStr(1,
objMailItem.Attachments.Item(i).filename, ".pif") Then
objMailItem.Attachments.Remove (i)
MsgBox "Suspicious attachment removed!"
End If
Next
Next
End Sub
 
G

Guest

This one should be error free
or at least it is in ol2003

Dim objInbox As MAPIFolder
Dim olitems As Items
Dim objMailItem As MailItem


Private Sub Application_NewMail()
Set objInbox = Outlook.Session.GetDefaultFolder
(olFolderInbox)
Set objitems = objInbox.Items

For Each objMailItem In objitems
If objMailItem.Class = olMail Then
For i = 1 To objMailItem.Attachments.Count
If InStr(1, objMailItem.Attachments.Item
(i).filename, ".bat") Or InStr(1,
objMailItem.Attachments.Item(i).filename, ".pif") Then
objMailItem.Attachments.Remove (i)
MsgBox "Suspicious attachment removed!"
End If
Next
End If
Next
End Sub
 
G

Guest

Whoops! Thats what you get for rushing me..

This time it saves the ammended mail item!

Dim objInbox As MAPIFolder
Dim olitems As Items
Dim objMailItem As MailItem


Private Sub Application_NewMail()
Set objInbox = Outlook.Session.GetDefaultFolder
(olFolderInbox)
Set objitems = objInbox.Items

For Each objMailItem In objitems
If objMailItem.Class = olMail Then
For i = 1 To objMailItem.Attachments.Count
If InStr(1, objMailItem.Attachments.Item
(i).filename, ".doc") Or InStr(1,
objMailItem.Attachments.Item(i).filename, ".pif") Then
objMailItem.Attachments.Remove (i)
objMailItem.Save
MsgBox "Suspicious attachment removed!"

End If
Next
End If
Next
End Sub
 
G

Guest

It will then fire each time a mail item is received.

all you need to do is paste the text straight into the
pane that pops up..

Don't select anything..

:)

Then send a test e-mail to yourself..
 
G

Guest

?? The e-mail ??

You mean the attachment?
Permanantly deleted....

Add this line before the remove line, and ammend as needed
objMailItem.Attachments.Item(i).SaveAsFile SaveAs
("C:\Quarenteen\" & objMailItem.Attachments.Item
(i).filename)



You can just extend the script if you wish:

If InStr(1, objMailItem.Attachments.Item
(i).filename, ".bat") Or InStr(1,
objMailItem.Attachments.Item(i).filename, ".pif") or
InStr(1, objMailItem.Attachments.Item
 
M

Mike Hudson

If you wanted to be really cleaver, I would remove the
msgbox line and do objmailitem.body = objmailitem.body &
vbcrlf & vbcrlf & vbclrf & "I removed an attachment from
this e-mail, cuz it may av been a virus!" I try to avoid
this because sometimes it removes the body of the e-mail
for no appernt reason ????¿¿¿¿
 

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