Batch file to print a folder of Outlook Express messages

Posted on 2011-02-14
Medium Priority
Last Modified: 2012-05-11
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.
Question by:avhfj
  • 3
  • 3
  • 2
  • +1

Expert Comment

ID: 34906970
/p mesgfilename will print



for all command line switches

Author Comment

ID: 34907259
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
LVL 39

Assisted Solution

BillDL earned 664 total points
ID: 34907575
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.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Accepted Solution

point_pleasant earned 668 total points
ID: 34908161
could yoou import them into outlook and then print?
LVL 39

Expert Comment

ID: 34908167
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.

Assisted Solution

sam0x01 earned 668 total points
ID: 34923045
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


Author Comment

ID: 34926785
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 http://www.emltopst.com/.
 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


Author Comment

ID: 34929643
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 :-)

LVL 39

Expert Comment

ID: 34932482
Thank you avhfj

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question