There are, however, separate products that can manage spam and anti-malware for Exchange and O365 on the server side.
F-Secure Anti-Virus for Microsoft Exchange for onpremises Exchange and Protection Service for Email for either on-premises email service or Office 365. It really makes more sense to do the email screening before the emails even get to the server. PSE also includes possibility for end-to-end email encryption.
Unfortunately, MAPI protocol is not supported by current versions of E-mail scanning and E-mail filtering. Malware in attachment will be detected when you try to open/save it.
Scanning for spam is not possible at all for this protocol.