The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
If you made sure you added your SharePoint site to the Trusted Sites zone and still the Open in Explorer is greyed out, Try this fix. It works every time for me!
Open the SharePoint site you are trying to "Map A Drive" to in your Edge browser in Internet Explorer mode.
To do this, open the SharePoint site you are trying to Map a Drive to or Open in Explorer in your Edge browser, then click the 3 dots to the right (Settings Menu) on your Edge browser then select Open in Internet Explorer mode. https://learn.microsoft.com/en-us/answers/questions/450116/how-to-enable-ie-mode-on-microsoft-edge.html
After your SharePoint site reopens in IE mode, then you can switch your SharePoint to classic view, click the Library tab and now Open in Explorer will not be greyed out.
Click Open in Explorer, once the Explorer window opens, you can now map a drive to that SharePoint site without receiving the error message "The mapped network drive could not be created because the following error has occurred: Access Denied. Before opening files in this location, you must first add the web site to your trusted sites list, browse to the web site, and select the option to login automatically."