none
How to Block Spam Emails with a Blank Receiver RRS feed

  • Question

  • Hi,

    I notice there are many spam emails whose receiver is blank. Therefore, I want to create a rule to move all such emails to a specific folder. Is there a way to do so via Outlook VBA?

    Thanks

    Friday, February 24, 2017 1:58 AM

All replies

  • Hi,

    Could you please share a screenshot of the emails "whose receiver is blank"?

    For normal mailitems, we could check its Recipient Object (Outlook) and then use MailItem.Move Method (Outlook) to move into specific folder.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 24, 2017 4:51 AM
    Moderator
  • Hi,

    Sure. Please kindly find a screenshot below:

    A spam email with empty receiver

    I mark the "Receiver" with a red rectangle. You can see it is completely empty.

    I receive many spam emails like this one, but from different senders.

    Thanks

    Friday, February 24, 2017 5:26 AM
  • Hi,

    Sorry that I don't have similar mailitems to test. If you run the code below, what would you get in the Immediate Windows (Please use Alt+F11 to open VBE and use Ctrl+G to open Immediate Windows )?

    Sub getReceivers()
    Dim oMailItem As MailItem
    Dim rec As Recipient
    Set oMailItem = Application.ActiveInspector.CurrentItem
    For Each rec In oMailItem.Recipients
    Debug.Print rec.Type; rec.Name
    Next
    End Sub

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, February 24, 2017 6:38 AM
    Moderator