PDA

View Full Version : How do i automatically delete messages from a certain sender?



gh83
12-19-2008, 07:37 AM
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!

gh83
12-19-2008, 08:38 AM
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.

gh83
12-21-2008, 07:37 AM
Nobody know the answer to this? Can it be done??

gh83
12-22-2008, 05:38 AM
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