# Outlook - Send Outlook email via command line w/attached file



## Tamizpa (Jun 5, 2007)

I would like to know if I could send an outlook email via command line while also attaching a file via command line. I am trying to have a Windows 2000 or 2003 server inititiate an email when it sees a certain text file arrive on the server. The email should run automatically with the file attached. I've found this attached link on how to do the command line: http://support.microsoft.com/kb/192341/en-us But no mention of attaching a file. Anyone have any ideas? Thanks!


----------



## Rollin_Again (Sep 4, 2003)

I would use Windows built in TASK SCHEDULER to fire a VBS script to check for the file and if found automatically email it.

There are multiple ways to accomplish this using the Outlook Object Model, MAPI Mail, or CDO mail. I'll try to post some examples in a bit.


Regards,
Rollin


----------



## Rollin_Again (Sep 4, 2003)

Tamizpa said:


> I am trying to have a Windows 2000 or 2003 server inititiate an email when it sees a certain text file arrive on the server.


Is this file going to be automatically saved or exported to a certain directory on the server or will the file be emailed to the server machine? We also need to know what type of naming convention will be used for this file. Will the file always be named the same and saved to the same location? Will the directory where the file will be saved to contain any other files? Will you be deleting or moving the file once it has been processed?

More details please.

Regards,
Rollin


----------



## Tamizpa (Jun 5, 2007)

Thanks for your quick response. It will have the same name each time. It will be a .txt file. (Don't have the exact name yet.) The file will be coming from the mainframe to the server. We want the file to be attached to the email, then have it deleted off the server once emailed. It should be the only file in the directory. Let me know if that's enough detail. I can make calls to find out more if needed.


----------



## Rollin_Again (Sep 4, 2003)

I need details about your email configuration. Is there a mail client installed on the server or will the mail be sent directly through your SMTP server? 

Regards,
Rollin


----------



## dmgaddy (Apr 8, 2008)

There are any number of command line mailers that can do what you are asking. Bmail or Blat for example.

HTH


----------



## Tamizpa (Jun 5, 2007)

We're planning on the customer putting a email client on the server. I was able to get more detail. Below's a synopsis of what we were thinking of doing. We're currently managing our customer's network with CA Concord's eHealth and they want Concord to do this alerting function for them --

Mainframe FTP&#8217;s File to Windows 2000 Server
Concord monitors Server for file and sends alerts upon seeing it.
In the alerting function, Concord can execute VBS script to run Outlook (via command line), email file to distribution list, then delete file.

After talking to my co-worker's here, they know how to monitor the server for the file, we just don't know about how to do VBS/Outlook command line or if it was doable. Our customer is using Outlook, so we don't want to use Blat or something else cause we won't be managing the actual server or email account...they will since it's their server. We're just trying to see if this scenario is doable. Thanks for all your help.


----------



## Rollin_Again (Sep 4, 2003)

All you need is the SMTP server address and port number and you can send the email automatically using CDO without having to install an email client. If you get that info I'll help you with the code. If you decide to use Outlook to send the email you will run into issues with the built in security prompt that is generated. There are workarounds but I find it easiest to just send the mail directly through the SMTP server unless you need to keep the sent mail items for historical purposes.

Regards,
Rollin


----------

