Exchange transport rules to reject messages without attachment

Hi,

 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 xxx@mydomain.com 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 xxx@mydomain.com -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 ?

 Thanks
Benj55Asked:
Who is Participating?
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:
hmm..
maybe we do it differently?

Reject all email from  xxx@mydomain.com
EXCEPT message header match the criteria?
0
Benj55Author Commented:
Hi,

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

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

do this meet your requirement?
0
Jian An LimSolutions ArchitectCommented:
the attached pic as this
TransportRules.PNG
0

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
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.