View Full Version : How do i automatically delete messages from a certain sender?
Does anyone know the code to automatically delete messages from a certain sender the moment they come into the inbox (i.e. not having to manually run a macro)?
Thanks!
Does anyone know the code to automatically delete messages from a certain sender the moment they come into the inbox (i.e. not having to manually run a macro)?
Thanks!
btw i know senders can be blocked automatically in outlook but i need the code as it may need to extend it.
Nobody know the answer to this? Can it be done??
I can make a message box appear whenever a message is received using the code below so is anyone help me with deleting the received message? I've asked on a couple of forums and had no response sop this is obviously more difficult than i thought!!
-----------
Public WithEvents olInboxItems As Items
Public Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
End Sub
Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
If Item.Class = olMail Then
MsgBox "test"
End If
End Sub
JP2112
12-30-2008, 08:45 AM
Why not use a rule instead? You can set up a rule to automatically delete messages from a specific sender. Otherwise just check the MailItem.SenderName or MailItem.SenderEmailAddress Property in your code below, inside the IF statement.
HTH
I can make a message box appear whenever a message is received using the code below so is anyone help me with deleting the received message? I've asked on a couple of forums and had no response sop this is obviously more difficult than i thought!!
-----------
Public WithEvents olInboxItems As Items
Public Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
End Sub
Private Sub olInboxItems_ItemAdd(ByVal Item As Object)
If Item.Class = olMail Then
MsgBox "test"
End If
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.