If you have a valid IHTMLDocument2 pointer, which you will get in
OnDocumentComplete by querying on LPDISPATCH that you got, you can use
IHTMLDocument3::get_documentElement to get the doc element and then call
get_outerHTML on it.if (!m_pHTMLDocument2)
    return;IHTMLDocument3* pHTMLDoc3;
HRESULT hr = m_pHTMLDocument2->QueryInterface(IID_IHTMLDocument3,
(LPVOID*)&pHTMLDoc3);
ASSERT(SUCCEEDED(hr));
IHTMLElement* pDocElem;
hr = pHTMLDoc3->get_documentElement(&pDocElem);
pHTMLDoc3->Release();
ASSERT(SUCCEEDED(hr));
BSTR bstrHTML;
pDocElem->get_outerHTML(&bstrHTML);
pDocElem->Release();
USES_CONVERSION;
MessageBox(OLE2T(bstrHTML), _T("Outer HTML Contents"));
SysFreeString(bstrHTML);