Window Service printing HTML

Hi

I have a windows service which creates a string containg HTML which I normally send as the body of an email. I know want to use that same string containg HTML and print it. Ive looked at the printing options using the graphics class but they want to A. build it one line at a time (I create one large string) and B. I'm not sure if it will keep the formatting created by the HTML.

Ive tried creating a web browser in the service but no luck...

WebBrowser objWB = new WebBrowser();
objWB.DocumentText = CreateMessage(); // returns string containg HTML "<html><head>..."
objWB.Print();

It complains about a single thread apartment. How do I get this working



Answer this question

Window Service printing HTML

  • Edward E. Weller

    It seems to complain when I add the web browser control.


  • Alex DeJarnatt - MSFT

    Have you tried

    object em =null;

    objWB.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT,
    SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
    ref em, ref em);


  • Window Service printing HTML