Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
3.4 KiB

  1. @echo off
  2. REM --- Set some defaults
  3. set keep=NO
  4. set binDrive=
  5. set from=y-juke
  6. REM --- Create the name of the message file based on the current date/time
  7. md \\bandsaw\c$\emailmsg > nul
  8. md \\bandsaw\c$\emailmsg\msgs > nul
  9. :datetime
  10. set msgFile=
  11. echotime /DHMS.msg | sed "s/^/set msgFile=/" > mftmp.bat
  12. call mftmp.bat
  13. del mftmp.bat
  14. if "%msgFile%" == "" goto noMsgFile
  15. set msgFile=\\bandsaw\c$\emailmsg\msgs\%msgFile%
  16. if exist %msgFile% goto datetime
  17. REM --- Check some old variables for upwards compatibility
  18. if not "%emailee%" == "" set name=%emailee%
  19. if not "%mailee%" == "" set name=%mailee%
  20. REM --- If sending a file with no name, assume AnthonyR
  21. if "%name%" == "" goto chkFile
  22. goto chkFileX
  23. :chkFile
  24. if "%file%" == "" goto noName
  25. if "%attach%" == "" goto noName
  26. set name=a-msmith
  27. :chkFileX
  28. REM --- Keep going
  29. if "%subject%" == "" set subject=(no subject given)
  30. if "%1%" == "/k" set keep=YES
  31. if "%1%" == "/keep" set keep=YES
  32. if "%1%" == "k" set keep=YES
  33. if "%1%" == "keep" set keep=YES
  34. echo Subject: %subject% >> %msgFile%
  35. echo To: %name% >> %msgFile%
  36. echo Cc: %cc% >> %msgFile%
  37. echo Bcc: %bcc% >> %msgFile%
  38. if "%attach%" == "" goto attachX
  39. if not exist %attach% goto attachX
  40. :attach
  41. echo Attach: %attach% >> %msgFile%
  42. :attachX
  43. if "%file%" == "" goto fileX
  44. if not exist %file% goto fileX
  45. :file
  46. echo.>> %msgFile%
  47. type %file% >> %msgFile%
  48. :fileX
  49. echo.>> %msgFile%
  50. :lock
  51. if not exist %binDrive%\bin\email.lck goto lockX
  52. echo Someone else sending mail. Sleeping 5 secs...
  53. sleep 5
  54. if not exist %binDrive%\bin\email.lck goto lockX
  55. echo Someone else sending mail. Sleeping 10 secs...
  56. sleep 10
  57. if not exist %binDrive%\bin\email.lck goto lockX
  58. echo Someone else sending mail. Sleeping 30 secs...
  59. sleep 30
  60. :lockX
  61. echo Sending email > %binDrive%\bin\email.lck
  62. :ftp
  63. echo EMAIL.BAT From: %from%
  64. echo To: %name%
  65. echo Cc: %cc%
  66. echo BCc: %bcc%
  67. echo Subject: %subject%
  68. echo Attach: %attach%
  69. echo File: %file%
  70. echo.
  71. echo Sent to file %msgFile%
  72. goto continue
  73. :continue
  74. del %binDrive%\bin\email.lck
  75. REM set name=
  76. REM set subject=
  77. REM set file=
  78. REM set attach=
  79. goto exit
  80. :noName
  81. echo EMAIL.BAT: ERROR - No email name to mail to.
  82. goto usage
  83. :noBin
  84. echo EMAIL.BAT: ERROR - Can't find EMAIL.FTP or EMAIL.SED
  85. goto exit
  86. :usage
  87. echo EMAIL.BAT usage:
  88. echo.
  89. echo set name = Email recipient(s)
  90. echo set cc = Cc recipients(s) (optional)
  91. echo set ccc = Bcc recipients(s) (optional)
  92. echo set subject = Subject Line (optional)
  93. echo set file = File of text to send as content (optional)
  94. echo set attach = File of text to send as attachment (optional)
  95. echo call email.bat
  96. echo.
  97. goto exit
  98. :noMsgFile
  99. echo EMAIL.BAT: ERROR in creating filename msgFile!
  100. goto exit
  101. :exit
  102. if "%keep%" == "NO" set name=
  103. if "%keep%" == "NO" set cc=
  104. if "%keep%" == "NO" set file=
  105. if "%keep%" == "NO" set attach=
  106. if "%keep%" == "NO" set subject=
  107. if "%keep%" == "NO" set from=
  108. set keep=
  109. set msgFile=