mailto

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
scienceguru1.bat
Posts: 44
Joined: 01 Jan 2011 20:54

mailto

#1 Post by scienceguru1.bat » 19 Jan 2011 20:50

how can i make a batch file that sends an email inculding to, subject, and message at the minimum. any other feilds would also be appreciated.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: mailto

#2 Post by aGerman » 20 Jan 2011 12:46

There is no native command in batch. 2 days before somebody had a similar question.

Regards
aGerman

scienceguru1.bat
Posts: 44
Joined: 01 Jan 2011 20:54

Re: mailto

#3 Post by scienceguru1.bat » 20 Jan 2011 14:35

i have tried a few programs with no success :(

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

Re: mailto

#4 Post by avery_larry » 21 Jan 2011 09:41

both blat.exe and sendemail.exe are very simple to use. google them to download. Post your command and error messages if you still have problems.

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: mailto

#5 Post by amel27 » 22 Jan 2011 02:11

try this sample batch SMTPSend function (JS inside):

Code: Select all

@set @x=0 /*
@echo off
::--- start proper batch ---

set SMTPsubj=Test Mail
set SMTPtext=Mail Text

call:SMTPSend "%~f0" smtp.srv.com userFrom@my.com userTo@my.com SMTPsubj SMTPtext
EXIT

:SMTPSend  BatchName, SMTP_Server, MailFrom, MailTo, Subject, MailText
  SETLOCAL EnableDelayedExpansion
  if "!%~2!"=="" (set "SMTPserv=%~2") else set "SMTPserv=!%~2!"
  if "!%~3!"=="" (set "SMTPfrom=%~3") else set "SMTPfrom=!%~3!"
  if "!%~4!"=="" (set "SMTPto=%~4"  ) else set "SMTPto=!%~4!"
  if "!%~5!"=="" (set "SMTPsubj=%~5") else set "SMTPsubj=!%~5!"
  if "!%~6!"=="" (set "SMTPtext=%~6") else set "SMTPtext=!%~6!"
  cscript //nologo /e:jscript "%~1" "SMTPSend('%SMTPserv%','%SMTPfrom%','%SMTPto%','%SMTPsubj%','%SMTPtext%')"
  ENDLOCAL
GoTo:EOF
::---- end proper batch ----
*/
eval(WScript.Arguments.Item(0));
// -------------------------
function SMTPSend(Server,From,To,Subj,Text) {
  var objEmail = WScript.CreateObject("CDO.Message");

  objEmail.From = From;
  objEmail.To = To;
  objEmail.Subject = Subj;
  objEmail.Textbody = Text;
//objEmail.BodyPart.CharSet = "utf-8";

  with (objEmail.Configuration.Fields) {
    Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2;
    Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")=Server;
    Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25;
//  Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1;
//  Item("http://schemas.microsoft.com/cdo/configuration/sendusername")="user";
//  Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")="pass";
    Update();
  }
  try {objEmail.Send();}
  catch(e) {
    WScript.Echo("ERR: "+e.number);
    WScript.Echo(e.message);
}}

scienceguru1.bat
Posts: 44
Joined: 01 Jan 2011 20:54

Re: mailto

#6 Post by scienceguru1.bat » 23 Jan 2011 16:25

SMTP: I just get an error message before the window closes, and I cant copy it because the window immediately closes after the text appears.
BLAT/Sendmail: The configs are too confusing, tried a lot.

If a made a SENDMAIL ASP form, then could you tell me how to fill it out?

Post Reply