Quantcast
Channel: Oracle Database Administration Blog » Tools
Viewing all articles
Browse latest Browse all 4

Dos batch to send email with Attachment

$
0
0

Command syntax:

  • febootimail -ATTACH image.jpg
  • febootimail -ATTACH *.doc -ATTACH 20??-file.gif
  • febootimail -FILE document.doc -ATTACH "C:\my music\music.mp3"
  • febootimail -FILE "image.jpg | C:\my music\music.mp3 | data.txt"

-ATTACH or -FILE switch specifies which files will be added to message when sending email from command line. If attachment file path is not specified, attachments are taken from the folder in which Febootimail is executed.

Since Febooti Command line email version 3.0 it is possible to use file masks (e.g. “*.*” or “files*.jp?”) with -ATTACH (or -FILE) parameter thus cancelling the need for batch files.

Pay attention that if spaces are used either in file name or folder name, expression has to be put in quotes. If many files are sent, -ATTACH switch must be repeated before each file or separate filenames by using | (pipe).

 
C:\>febootimail -SERVER smtp.server.com -FROM jack@sender.com -TO john@recipients.com -ATTACH "c:\My Presentations\presentation.ppt | c:\terms\terms.txt" -TEXT DOS mailing out presentation and term files as attachments

Text files can be sent out either as plain message or as attachment. In the latter case text file formatting will not be interpreted arbitrary by email clients, so that it is useful to send text files as attachments if every byte has to be preserved as is.

 
C:\>febootimail *other mail parameters* -ATTACH plaintextfile.txt -TEXT "send e-mail from DOS with text file attachment"

If many files are to be sent as attachments with command line mail utility, it is most convenient to create batch file.

 
@echo off
rem send all files as attachments. one attach per email...

for %%i in (*.*) do Febootimail *other params* -ATTACH %%i

Note that (*.*) stands for file mask where (*.*) means that all files will be sent as attachments. If (*.doc) is used, all files with extension .doc will be sent. If (??-dec*.d?c) is specified, only files that have “-dec” in their names as 3rd to 6th characted and extension that starts with “d” and ends with “c” (with 2nd character being any) are to be sent.

Also, note that in example above every file is sent as separate email. If all files have to be attached to single email message, use the batch files from example given below.

 
@echo off
rem this is batch file - do.bat
rem will call batch file - send.bat

cmd /v /c send.bat

rem /v - delayed environment variable expansion
rem /c carries out the command specified by string
rem Call this file from Windows 2000 / XP / 2003 / Vista

 
@echo off
rem batch file - send.bat must be called from file do.bat

rem Gathering all files in current folder with mask specified...
dir *.doc /A-D /B > tmp

rem Expand environment variable attach as long as needed...
for /F "tokens=*" %%i in (tmp) do set attach=!attach! -ATTACH %%i

rem Send all files / attachments in single email...
febootimail <standard params excluding -ATTACH> %ATTACH%

rem Cleaning temporary file...
del tmp

 
Download febootimail from following Link.

http://www.febooti.com/products/command-line-email/online-help/commands/dos-e-mail-automate-attachment-sending.html


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images