Exchange transport rules to reject messages without attachment


 I'm looking for a way to create a transport rule with Exchange 2013 on premise, which permit to "Reject the message with explanation" for incoming email sent to which do not contains any attachment.
 So, only emails with attachments should be accepted.

fred3rd always give me a way for using header patterns, but unfortunately, it doesn't works because Exchange rules don't accept blank character.

The rule is :
New-TransportRule -SentTo -HeaderMatchesMessageHeader 'X-MS-Has-Attach' -HeaderMatchesPatterns @('') -RejectMessageReasonText 'Send An Email With Attachment' -Name 'Reject Email Without Attachment'

So, using :

are not accepted and return :
 "a regular expression specified for a transport rule must contain at least one non-blank character".

Any idea ?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jian An LimSolutions ArchitectCommented:
maybe we do it differently?

Reject all email from
EXCEPT message header match the criteria?
Benj55Author Commented:

It should be a solution, but I found the "X-MS-Has-Attach" header is not included from email received from... provider ?!

Jian An LimSolutions ArchitectCommented:
I have tried this on the office 365 platform and i have this

do this meet your requirement?
Jian An LimSolutions ArchitectCommented:
the attached pic as this

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.