Hi NEAHR Mohamed. There are 2 ways to achieve this. 1st - using Application Control. Only allow Office365 related applications. 2nd - using ISDB. Only allow IP address of Office365 related.
However, version 5.2.7 is already obsolete and no engineer support/signature will be release anymore. Signature keep changing from to time and i would suggest to upgrade the Fortigate to major version 6.2, 6.4 or 7.0. So you will have latest update on the signature database to achieve your requirements effectively.
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.