• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 244
  • Last Modified:

COPY FORM BACTCH and then EMAIL FROM A BATCH FILE

I am in the process a creating a batch file that copies files between servers.

Would like to be able to send an email to the end user when the batch process is complete and successful.

Would like to include (just the names of the files)  in the email the files that were copies, the size, and date/time stamp.

I have done some pretty basic scripting things in the past but is a little different.
0
yostnet
Asked:
yostnet
2 Solutions
 
subhashchyCommented:
i think you can go this way..just basic script.If modificaation needed do

@echo off
set source=source_File_name
set destination=Destination_Flie_name
xcopy %source% %destination%

cscript /nologo sendemail.vbs

Open in new window


you shold create a VB script with below conect in the same folder.

'Script to send email
'Configuration Field,Modify below..

SMTPServer = "yoursmtpserver_IP_OR_NAME"
Recipient = "THE_EMAIL_RECIPIENT"
From = "THE_EMAIL_FROM_ID"
Subject = "Test email"
Message = "THE EMAIL SUBJECT"

'If there is no attachment needed,Remove or comment above line.
'To comment the line,just add " ' " before the line.
'DO not modify anything below this line.

GenericSendmail SMTPserver, From, Recipient, Subject, Message

Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message)

set msg = WScript.CreateObject("CDO.Message")
msg.From = From
msg.To = Recipient
msg.Subject = Subject
msg.TextBody = Message
msg.Configuration.Fields ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
msg.Configuration.Fields.Update
msg.Send
End Sub

Open in new window


Make sure to modify the configuration feild of VBS according to your Email server config..
0
 
Bill PrewCommented:
Another approach for sending email right from a BAT file is to use the BLAT util (plenty of samples and articles on EE on this).

http://www.blat.net/

~bp
0
 
ReneGeCommented:
What if you write something that looks like a batch file and that would contain words/commands that represents the logic and processes of what you want to do? The objectif is not that it works, it's just so we can have a clear picture.
0
 
subhashchyCommented:
 ^^^  +1
0
 
yostnetAuthor Commented:
thanks for the help
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now