"Items in this message are still loading.." Error using .PrintOut

R

RichW

I am using the XP PIA and .NET.

I have code that prints email messages to .pdf files - and things have
been running smoothly until I came across a small .pst file that had
some large messages. The code snippet is below.

I am wondering if there is any way to ensure a message is "fully
loaded" before I execute the .PrintOut method. This is unusual
because the .PrintOut method is a void - so nothing is returned.
Furthermore, I don't get any type of an error message; instead I get a
dialog box.

Ideally, if I could loop until a message property has the needed value
and then execute the method...

Any wisdom on this would be most appreciated.

Best,

- Rich

snippet
****************************************
// Print message if print setting is True
if (PFile.printJobID > 0)
{
try
{
string strPFName = PFile.printFname = strFileInfoID;
string PrintSubPath = PFile.printPath;
string strSubDir;
if (Counter.printCount == PRINTMAX)
{
sessionInit(MI.EntryID, PFile.folderPath);
return "Reset";
}

SetFilename(ref strPFName, ref PrintSubPath, out strSubDir);
PrintSubPath = strSubDir;
MI.PrintOut(); // Here is where the error is generated.

// Write record to PrintOutput table
strResult = pstutils.InsertPdf(PrintSubPath, strPFName,
System.Int32.Parse(strFileInfoID), PFile.printJobID);
}
catch (System.Exception ex)
{
WriteLogOutput("PDF Print Output error for message " + strEntryID +
CRLF
+ "From .pst file: " + PFile.fileName + CRLF
+ "Error message: " + ex.Message);

MI = null;
}
}
 
R

RichW

Update: I did get a response from Sue Mosher on another post.
Evidently, there is a property that can be interrogated. She
recommended using Inspector.HTMLEditor to return an HTMLDocument
object, then loop until its readystate property returns Complete.

I am actually trying to do this but am running into a problem. Below
is the snippet:
(I set a reference to Microsoft.mshtml)
(where oMsg is a reference to a mailItem):

Microsoft.Office.Interop.Outlook.MailItem MI =
(Microsoft.Office.Interop.Outlook.MailItem) oMsg;
IHTMLDocument2 oInspect;

Microsoft.Office.Interop.Outlook.Inspector Inspect =
(Microsoft.Office.Interop.Outlook.Inspector) MI.GetInspector;

// Here is where I use Inspector.HTMLEditor to return an HTMLDocument
object
oInspect = Inspect.HTMLEditor;

Unfortunately, the above statement does not compile. I get the error:
Cannot implicitly convert type 'object' to 'mshtml.IHTMLDocument2'

As before, any wisdom on this would be greatly appreciated.

Best,

- Rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top