Restrict Mail App outside of ip address

I want to restrict users from accessing mail app outside of office network. I have used file access control to block files, but I need a solution for blocking MAIL APP. I have configured a internal mail server. and I need nextcloud accessible from outside for public file sharing,