public static string MonikerToString(IMoniker moniker, uint codepage, out string url) { // Create binding context that will be needed to get the url from the moniker IBindCtx bindCtx; int hr = Ole32.CreateBindCtx(0, out bindCtx); if (hr != HRESULT.S_OK) throw new COMException("Error creating binding context", hr); // Get the url of the moniker string name; moniker.GetDisplayName(bindCtx, null, out name); url = name; // Get a stream to the content of the url IStream stream; ComHelper.Chk(UrlMon.URLOpenBlockingStream(IntPtr.Zero, name, out stream, 0, null)); // Read the contents of the url, which should be the html to an email message using (ComStream comStream = new ComStream(stream, false)) { using (StreamReader sr = new StreamReader(comStream, Encoding.GetEncoding((int)codepage))) { return sr.ReadToEnd(); } } }
/// <summary> /// Create an OleStgMediumSTREAM that encapsulates the passed STGMEDIUM /// </summary> /// <param name="stg">Underlying STGMEDIUM</param> public OleStgMediumISTREAM(STGMEDIUM stg) : base(stg) { // validate that the correct type has been passed in ValidateType(TYMED.ISTREAM); // initialize the .NET stream m_stream = new ComStream((IStream)m_comObject); }