Solved

How to send an email using a windows batch file in XP

Posted on 2010-11-10
12
866 Views
Last Modified: 2012-05-10
I am new to batch file and trying to do some things with it.  Can someone let me know how to send an email using Windows Batch File.  I am assuming that this can be done!


Many thanks
Sandy
0
Comment
Question by:sweetiepie70
12 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 84 total points
ID: 34108059
When using batch files I like to use blat for sending emails.
http://sourceforge.net/projects/blat/files/
0
 
LVL 52

Assisted Solution

by:Bill Prew
Bill Prew earned 83 total points
ID: 34108414
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 34108425
0
 

Assisted Solution

by:escadavid
escadavid earned 83 total points
ID: 34108992
Hi there

You can use a simple command line tool like CSSMTP
-  http://www.codestone.co.uk/software/bin/cssmtp/CSSMTPSetup17.msi


Here is an example to use it, in order to copy some files from a directory to another computer. Whole "REM" lines are comments.
-------------------------------------------------
REM  Put in the source directory
cd c:\backupdp
REM Trying to copy any files with *.bak extension
copy *.bak \\192.168.10.254\F$\Backup
REM Validating if the copy was successfull then skip the ErrProc procedure
If %errorlevel%==0 Goto Success
REM If was not successfull then
:ErrProc
cd C:\backupdp
REM Create a file called Error.log with a message
echo Backup of .bak files were NOT success > Error.log
REM This is the line to send the email to 2 addresses with a subject of "Copy Failed" and attaching the file Error.log
CSSMTP.exe -h192.168.10.37:25 -edavid@acme.com -rlsam@acme.com -s"Copy Failed" -fC:\backupdp\Error.log
Goto End

:Success
cd C:\backupdp
Del *.bak
Del *.txt
echo Backup successfull> Backup.log

:End
Echo End Process
-----------------------------------------------------

Hope it helps.
0
Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

 
LVL 52

Expert Comment

by:Bill Prew
ID: 34277385
On this one I think a number of viable answers to the question were posted, and should be recognized.  Perhaps just an equal split to all contributors.

~bp
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 34277391
Sorry, but there are many questions posted like this, and the list of tools presented here does not add something new. Without the asker choosing any, and giving a reason why, I think retaining the question is useless.

Qlemo
Cleanup Volunteer
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 34277416
Okay, you moderators see the bigger picture better than I do, thanks for the feedback and your contributions to keep EE clean and robust.

~bp
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 34278267
> Sorry, but there are many questions posted like this, and the list of tools presented here does not add something new.
> Without the asker choosing any, and giving a reason why, I think retaining the question is useless.

I disagree.  This is the attitude I see on other sites, but EE has, since I can remember, never enforced preventing duplicate questions from different individuals.  If EE wants to, the time to do so is when the first question is asked, NOT when people have contributed their valuable time answering the questions.  Some of the experts who have provided information here may be trying to earn free memberships and it's not right to tell them you get nothing for this question because we have so many like it already, again, when this has not been done in the past.

I won't object again, but think this is an important point for every badger to remember and wanted to make sure it was seen.
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 34278564
Thanks for the support leew.

~bp
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now