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

Author Topic: send a .txt file from a batch to mail box  (Read 4463 times)

0 Members and 1 Guest are viewing this topic.

Riccardo

  • Guest
send a .txt file from a batch to mail box
« on: December 06, 2005, 03:52:58 AM »
Hi Guys,

Is it possible send a .txt file to a mail box (and then sen it with outlook) directly from a batch file?

Thaks,
Ciao
Riccardo

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: send a .txt file from a batch to mail box
« Reply #1 on: December 06, 2005, 05:34:34 AM »
There are probably 3rd party products that will let you do this from a batch file (try googling for them) otherwise you can use a script:

Code: [Select]

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "youremailaddress.com"
objEmail.To = "recipientsmailaddress.com"
objEmail.Subject = "subject"
objEmail.Textbody = "Body"
objEmail.AddAttachment "attachfilename"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configurati
on/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configurati
on/smtpserver") = "yourmailserver"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configurati
on/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send


In the from parameter, put your email address. In the to parameter, list the addresses of who you're sending the email. Separate with semi-colons if multiple addresses. In subject and body put anything appropriate. In the attachments parameter put the path and file name of your file. In the smtpserver parameter, put your email servername. You may have to check with your ISP for this info, although most ISP's have this info on their web sites. Do not change the rest of the parameters.

Save the file with a VBS extension and run from the command line as cscript scriptname.vbs

Good luck.  8)

This question has been asked and answered numerous times before. Please research your question before posting.
« Last Edit: December 06, 2005, 05:36:52 AM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

Riccardo

  • Guest
Re: send a .txt file from a batch to mail box
« Reply #2 on: December 06, 2005, 10:41:45 AM »
Thanks SideW

I'll try. ;)

thake care
Riccardo

Riccardo

  • Guest
Re: send a .txt file from a batch to mail box
« Reply #3 on: December 06, 2005, 10:53:02 AM »
SideW, or who want to help,

What if i try to call the Vbs script with the  "call" command from the batch file?

thanks,

Riccardo

Blackberry



    Adviser
  • For those with wings, fly to your dreams.
    Re: send a .txt file from a batch to mail box
    « Reply #4 on: December 06, 2005, 11:03:02 AM »
    if the script is correct, that should work... (the call command) how to use it

    call [drive][directory]
    example: c:/test.vbs
    Everybody knows you can't click here. But I know you will try it :)

    riccardo

    • Guest
    Re: send a .txt file from a batch to mail box
    « Reply #5 on: December 06, 2005, 11:08:06 AM »
    Hi SideW

     When i run the script i got an error like this:

    *.vbs(7, 82) Microsoft VBScript Compilation Error: string without termination.

    What can it be?

    Ciao
    Riccardo

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: send a .txt file from a batch to mail box
    « Reply #6 on: December 06, 2005, 06:12:49 PM »
    Apparently you ran into a limitation of the forum. Some of the lines you see as two lines were written and need to be just one line unless you use continuation.

    All lines preceeded by:  objEmail.Configuration.Fields.Item (and followed by another line) need to be one line in your editor.

    Hope this helps.  8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    riccardo

    • Guest
    Re: send a .txt file from a batch to mail box
    « Reply #7 on: December 07, 2005, 08:16:25 AM »
    Ciao SideW,

     Yes you were right, actually i found it  few second after i posted it.... :( sorry for bother you for such a stupid thing.

    but now when i run it i have this error msg:

     *.vbs(6, 1)  CDO.Message.1: the specified protocol is unknow


    This is the 6th line  :
    objEmail.AddAttachment "ciao_12.txt"

    For wich reason should be the protocol Unknow?

    Ciao
    Ric

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: send a .txt file from a batch to mail box
    « Reply #8 on: December 07, 2005, 10:57:20 AM »
    You need to use a fully qualified file name for the attachment.

    Example: "drive:\dir1\dir2\ciao_12.txt"

    Hope this helps.  8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    Riccardo

    • Guest
    Re: send a .txt file from a batch to mail box
    « Reply #9 on: December 08, 2005, 08:38:03 AM »
    ...getting closer,

    Yuor last tip worked, but now look at this, it seems like the mail server doesn't get the command :

    *.vsb (11,1) (null): the message could not been sent to the SMTP server.
    0217. the server response was not available

    ciao
    Ric

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: send a .txt file from a batch to mail box
    « Reply #10 on: December 08, 2005, 10:13:51 AM »
    You may have missed the instructions that went along with the code:
    Quote
    In the from parameter, put your email address. In the to parameter, list the addresses of who you're sending the email. Separate with semi-colons if multiple addresses. In subject and body put anything appropriate. In the attachments parameter put the path and file name of your file. In the smtpserver parameter, put your email servername. You may have to check with your ISP for this info, although most ISP's have this info on their web sites. Do not change the rest of the parameters.

    You didn't post your script so my guess is that the smtpserver parameter is in error. Do you host your own email? If you do check with your network administrator or else you may have to check with your ISP for details.

    8)
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein