Batch file to print a folder of Outlook Express messages

I need to print a folder-full of Outlook Express (.eml) messages as part of an auditing application.  I can look at the messages using the following batch file:

@echo off
for %%X in (.\MailX\ReviewSample\*.eml) do "C:\Program Files\Outlook Express\msimn.exe " /eml:%%X

But how I can I just print them?  Also, does anyone know where I can find the complete list of command line options for Outlook Express?

Thanks, Experts.
Who is Participating?
point_pleasantConnect With a Mentor Commented:
could yoou import them into outlook and then print?
/p mesgfilename will print


for all command line switches
avhfjAuthor Commented:
Thanks for the reply, point pleasant.  That page is for Outlook, though, not for Outlook Express.  I tried your suggestion with Oulook Express, just in case (C:\Program Files\Outlook Express\msimn.exe /p [messagefilename]), but it didn't work.  

If anyone knows the link to the exact same information for Outlook Express, that's what I'm after.

Thanks again,  . . .  avhfj
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

BillDLConnect With a Mentor Commented:
avhfj is asking about Outlook EXPRESS in Windows XP, not Microsoft Office Outlook.

Outlook Express (msimn.exe) actually only supports 3 command line options, and none are of any use to avhfj:

msimn.exe /outnews
msimn.exe /newsonly
Starts OE in News Reader Only mode. You cannot send or receive e-mail, and the Mail tab in the Internet Accounts dialog box is missing.

msimn.exe /mailonly
Starts OE in Mail Only mode.  You cannot view newsgroups, and the News tab in the Internet Accounts dialog box is missing.

Outlook Express was never written to allow command line usage.  msimn.exe does not support the /p (print) switch.  I have tried every permutation possible in the past to do this, and it does not work.  The /p switch only usually works where a file extension is registered with a shell/print/command.  The *.eml file type does not have this registered.

The nearest you will get to automating it is to try messing around with a VBScript that uses the "SendKeys" function to simulate "accelerator key" presses, but the hard thing is bringing the window back into focus each time so that the simulated keypress is sent to that and not some other window that pops up to interfere with the process.

There are utilities that allow you to walk through the steps you would be performing on a repeating basis, build up a macro-based script as you go, and compile it into an executable, for example AutoIT:

Often these use the "WindowTitle" to determine the item to be brought into focus and have the script actions applied to it, but the "Window Title" is different in each opened message and I don't think you could use that.  Even the Window Class Name of "ATH_NOTE" cannot be relied upon, because that applies to the "Compose Message" windows also, so this utility would fail:
It gets very complicated tracking Handles and Child Handles to try and get this kind of thing done in a scripted way.

I am not a programmer though, and perhaps an expert in this field will be able to devise a VBScript or similar to do what is needed.
Just thinking out lod here.

Ctrl + P works to print to the default printer after an *.eml file is opened (as long as the window is in focus), so in theory it's just a case of then finding a way to make sure the window stays active while it is sent the code for Ctrl + P with SendKeys:

WshShell.SendKeys "^P"   (have to check the syntax though)

Here's something that MIGHT just work.  Check and see if the text in the Title Bar of the window matches the file name of the *.eml file that opens with your command.  I am sure that it won't, because it normally applies the subject line of the email message as it would show in Outlook Express, rather than the file name of a saved *.eml file as it shows in Windows Explorer.  I believe that I am correct in guessing that the file name might be truncated, and special characters being converted to underscores, depending on how the eml files were actually saved out from OE, so there's yet another potential complication.

If your file names were saved out in such a way that they are named the same as the subject lines, then it MAY be possible to actually use the file name, with a workaround for underscores replacing reserved characters, of the eml file and use that as the Window Title to apply the focus to for a Ctrl + P keystoke to be sent to it.

If not, then it may be possible to search the eml file, find the "Subject:" line, and store that as a variable for re-use in a VBScript. The only issue I see with this is that, opened in Notepad, the "Subject:" line in some of my saved eml files break over onto a 2nd line and trying to grab the complete subject line would fail.

I think you will agree that the SendKeys concept is beginning to look a bit flawed, but check the file names vs subject lines anyway and let us know.
sam0x01Connect With a Mentor Commented:
If you have access to MS Outlook, perhaps an alternative (and easier) way would be to

Script exporting the Outlook Express to a PST file (a lot easier with SendKeys or AutoIT)
Copy the PST file (ideally to a central location, suggest using the Computername env variable in the name)
Work out a script to import PST into Outlook. print and remove PST from Outlook

avhfjAuthor Commented:
point pleasnt, billDL and sam0x01:  I am very grateful for your suggestions.  I am going to fo with a combination of your ideas, so, if you have no objection, will split the point between you:
I'll convert the .eml files to .pst using a batch convert program, such as at
 I'll use the Outlook command line option suggested to print the files.

The reason I haven't tried Outlook before is because I am unlucky/unskillful at installing new applications.  The idea of installing Outlook just for this little (though important for my employers) just for this little task seemed unattractive, but your comments have made me realized I have to bite the bullet.

By the way, point pleasant, the Outlook Express command lines  set out in MS Article ID: 177233 CANNOT be the only command line options for OE.  There is at least one more: the option I found (in a very old message on another help site) to view .eml files:
msimn.exe " /eml:[filename]

Thanks again everyone,  . . .  avhfj

avhfjAuthor Commented:
Text of my email to Customer Service:

Question ID 26821144  Oops!

Dear Customer Service:

I had three experts, point pleasnt, billDL and sam0x01, respond to my question, all of whom were very helpful.  I meant to divide the 500 points I offered in equal  shares (less rounding) among the three of them, but managed to  award two shares to billDL and none to point pleasant.  Is there a way to correct this?  

Thanks, . . .   avhfj.

Sorry, point pleaseant :-)

Thank you avhfj
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.