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

Author Topic: email batch file  (Read 6607 times)

0 Members and 1 Guest are viewing this topic.

rajah

  • Guest
email batch file
« on: December 06, 2006, 07:19:53 AM »

Hi all,

I need a batch file that would pick my designated html file from a directory and send as an email to an email address

thanks in advance

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: email batch file
« Reply #1 on: December 06, 2006, 09:32:29 AM »
Not sure you can do this in batch without a 3rd party program. Windows Script however offers a solution:

Code: [Select]
Set CDO = CreateObject("CDO.Message")
CDO.From = "youremailaddress"
CDO.To = "receipientaddress"
CDO.Subject = "text"
CDO.Textbody = "moretext"
CDO.AddAttachment "attachedfilename"
CDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
CDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "youremailservername"
CDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
CDO.Configuration.Fields.Update
CDO.Send

From, To, Subject, TextBody parameters should be self evident, change as needed. AddAttachment should be the path of the file you want to attach to the email. Change the SMTP server name to your ISP outgoing mail server name. Do NOT change any other parameters.

After saving the script with a vbs extension, you can run it as cscript scriptname.vbs

The script can also be launched from a batch file  ;)

 8-)

From your PM's I got the information that you're using XP.
« Last Edit: December 06, 2006, 01:05:32 PM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

uli_glueck

  • Guest
Re: email batch file
« Reply #2 on: December 07, 2006, 03:20:38 AM »
To do it with a batchscript you need a 3rd party tool for mailing.
Blat is a good one. Just google for the downloadlink.

hope it helps
uli

rajah

  • Guest
Re: email batch file
« Reply #3 on: December 07, 2006, 01:06:59 PM »
thank you sidewinder ..your code worked for me..i saved it as vbscript file and ran it ..mails were created and deleivered..but i also have another task..i need to use this file to be called in the dos batch file ..is that possible???

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: email batch file
« Reply #4 on: December 07, 2006, 03:17:56 PM »
Just add the command cscript path\scriptname.vbs into your batch file just like any other command. If necessary add path information so Windows can find your script.

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

-- Albert Einstein

Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: email batch file
« Reply #5 on: January 21, 2009, 02:18:15 PM »
Code: [Select]
Set CDO = CreateObject("CDO.Message")
CDO.From = "youremailaddress"
CDO.To = "receipientaddress"
CDO.Subject = "text"
CDO.Textbody = "moretext"
CDO.AddAttachment "attachedfilename"
CDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
CDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "youremailservername"
CDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
CDO.Configuration.Fields.Update
CDO.Send

So, if my email was [email protected] then I would put that as CDO.From, and "youremailservername" would be thisisnotreal.com???

Edit, tried what I assumed...lagged then brought an error...
« Last Edit: January 21, 2009, 02:51:14 PM by Helpmeh »
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: email batch file
« Reply #6 on: January 21, 2009, 03:48:53 PM »
Code: [Select]
Set CDO = CreateObject("CDO.Message")
CDO.From = "youremailaddress"
CDO.To = "receipientaddress"
CDO.Subject = "text"
CDO.Textbody = "moretext"
CDO.AddAttachment "attachedfilename"
CDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
CDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "youremailservername"
CDO.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
CDO.Configuration.Fields.Update
CDO.Send

So, if my email was [email protected] then I would put that as CDO.From, and "youremailservername" would be thisisnotreal.com???

Edit, tried what I assumed...lagged then brought an error...

Check with your ISP or visit their web site, but I doubt thisisnotreal.com is the name of their SMTP mail server.

 8)

A reminder: never ASSUME
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: email batch file
« Reply #7 on: January 21, 2009, 04:03:40 PM »
Umm...Why would my ISP know what the SMTP of rocketmail.com is???

If anyone knows, please tell.
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: email batch file
« Reply #8 on: January 21, 2009, 05:01:32 PM »
Umm...Why would my ISP know what the SMTP of rocketmail.com is???

If anyone knows, please tell.

They wouldn't. Well they might, but CDO is designed to send mail through a SMTP server. I doubt any web based mail site (Hotmail, Yahoo, Microsoft Live) will allow direct access to their SMTP servers.

I chose CDO as a solution to the OP to show that there are tools on most systems that many people overlook.

Why did you choose to resurrect a two year old post where the OP is no longer a member?

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

-- Albert Einstein

Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: email batch file
« Reply #9 on: January 21, 2009, 05:21:21 PM »
I didn't even notice how old this thread was. I just found a link in a recent thread on the same subject(Which btw you put).
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.