Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: how to send email from dos bat file with a date on it  (Read 12612 times)

0 Members and 1 Guest are viewing this topic.

jassie

  • Guest
how to send email from dos bat file with a date on it
« on: June 01, 2011, 12:53:55 PM »
 I have IT experience with programming how I have not worked with a DOS batch file before. I need to send an e-mail message to selected users when certain DOS Batch files are executed. In these e-mail message, I need to include the date and time the dos batch jobs were executed.

  Thus can you tell me how to send an e-mail message from a dos batch file that has the date and time on it also?

Cheezey



    Rookie

  • Cheese.
  • Thanked: 1
    • Computer: Specs
    • Experience: Experienced
    • OS: Unknown
    Re: how to send email from dos bat file with a date on it
    « Reply #1 on: June 01, 2011, 09:51:02 PM »
    Well, there's a weird and complicated way, but I would recommend for sending emails downloading something like www.petri.co.il/software/mailsend105.zip
    Or, use a batch file to output some VBScript code:
    That %date% will have the date stored in it, but read computerhopes's documentation on that because that will have no value of its own.
    Code: [Select]
    echo Set objEmail = CreateObject("CDO.Message") >> mail.vbs
    echo objEmail.From = "[email protected]" >> mail.vbs
    echo objEmail.To = "[email protected]" >> mail.vbs
    echo objEmail.Subject = "Server is down!" >> mail.vbs
    echo objEmail.Textbody = "Date: %date% Server100 is no longer accessible over the network." >> mail.vbs
    echo objEmail.Send >> mail.vbs
    start mail.vbs
    del mail.vbs
    Hope it helped. :)
    Education is the only thing interfering with my learning.
       - Albert Einstein

    Cheezey



      Rookie

    • Cheese.
    • Thanked: 1
      • Computer: Specs
      • Experience: Experienced
      • OS: Unknown
      Re: how to send email from dos bat file with a date on it
      « Reply #2 on: June 02, 2011, 04:12:23 PM »
      Whoops, my bad, %date% does actually have a value. So you can copy my code and change the stuff in quotations, just remember that when you type %date% it will turn into the date.
      Education is the only thing interfering with my learning.
         - Albert Einstein

      a117yogi



        Rookie
        • Experience: Guru
        • OS: Windows XP
        Re: how to send email from dos bat file with a date on it
        « Reply #3 on: June 03, 2011, 01:56:59 PM »
        http://www.ianr.unl.edu/internet/mailto.html
        you can use these codes just remove the html format and use
        start mailto:

        use %date% and %time% for the stamps
        use quotes in some places to get it to work the way you want without quotes it wont execute but with they are printed on the email, move them around and see if you can get it to work right
        start mailto:[email protected]?subject="subject %time%%date%&body=body goes here"