'WebBrowser Copy/SelectAll Command not working C#

I've came across the following way to convert a HTML Document into RTF in C#.

private static byte[] HtmlDocumentToRtfBytes(string html)
{
    var rtbTemp = new System.Windows.Forms.RichTextBox();
    var wb = new System.Windows.Forms.WebBrowser();
    wb.Navigate("");

    var doc = wb.Document.OpenNew(true); 
    doc.Write(html); 

    wb.Refresh(); 
    wb.Document.ExecCommand("SelectAll", false, null);
    wb.Document.ExecCommand("Copy", false, null);

    rtbTemp.SelectAll();
    rtbTemp.Paste();

    return Encoding.ASCII.GetBytes(rtbTemp.Rtf);
}

But unfortunately there seems to be an issue with the WebBrowser when either executing the "SelectAll" or "Copy" command, since when I check the contents of the RichTextBox it only contains the things I had in my clipboard before executing the program.

The method is run inside a COM Add-In for Microsoft Outlook. The .NET Version is 4.7.2



Solution 1:[1]

Apparently you need to enable programmatic access to the clipboard in your IE Internet Settings.

https://i.stack.imgur.com/Fm3X2.png

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 0xef