Link to home
Create AccountLog in
Avatar of avhfj
avhfj

asked on

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.
Avatar of point_pleasant
point_pleasant
Flag of United States of America image

/p mesgfilename will print

see

http://office.microsoft.com/en-us/outlook-help/command-line-switches-HP001003110.aspx

for all command line switches
Avatar of avhfj
avhfj

ASKER

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
SOLUTION
Avatar of BillDL
BillDL
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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)

http://ss64.com/vb/sendkeys.html
http://www.devguru.com/technologies/wsh/quickref/wshshell_SendKeys.html

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.
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of avhfj

ASKER

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

 
Avatar of avhfj

ASKER

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