ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Need help writing a script? Have any question about ScriptFTP?
Hello,

I was wondering if it was possible to attach the files downloaded and email them when downloaded?

I have a script that downloads audio files once every hour. They are voice mails. The way my server is set up, I have to manually pull the files from the remote server onto another networked server. Then I play them from the networked server on my comptuer (network place/shares) and listen to the voice mail.

What I;d like to do is attache the voice mail to an email and send it to myself using cmd. I don't have "blat," and I was wondering if its possible to send it through Outlook express which is installed on the server or if I can use telnet to send the email? (I have a working smpt server and tested out the telnet send email succesfully)

Here is the script that I currently use:
(I copied parts of several scripts and am trying to refine it so take it easy on me if you see some rookie mistakes. The point is it currently works to log the process as well as give me a txt file in each voice mail directory that gives me the path to each file. Someday I'll grab this file and make links to the file to listen to the voice mails thorugh the web.)
Code: Select all# Get the current date $date=GETDATE() # Concatenate "BACKUP", the current date and ".txt" to build the log file name $logfile="D:\Strata_Audio\Logs\vmLog-".$date.".txt" # Start logging LOGTO($logfile) # Remote directory where the 50 directories are located $remote_directory="vox/messages" # Local directory where the files are downloaded $local_directory="D:\Messages" # Connect to server, put your own settings here $result=OPENHOST("ftp.myftpsite.com","myuser","mypw") # If connection failed stop IF($result!="OK") STOP END IF # Change the current local directory. $result=LOCALCHDIR($local_directory) # If LOCALCHDIR failed stop the script IF($result!="OK") STOP END IF # Change the current remote directory. $result=CHDIR($remote_directory) # If CHDIR failed stop the script IF($result!="OK") STOP END IF # Once reached this point we are connected and ready # to browse the remote 50 directories with 2 subdirectories # in each one and a bunch of files in them ready for download.   # Get the remote directory listing # it should retrieve 50 items. $result=GETLIST($list,REMOTE_DIRECTORIES) # If GETLIST failed stop the script IF($result!="OK") STOP END IF # For each directory in $list... FOREACH $directory IN $list # Change current remote directory to that     # subdirectory CHDIR($directory) # Create a local directory with the same name     # and change current local directory to it.     # LOCALMKDIR may fail because it already exists LOCALMKDIR($directory) LOCALCHDIR($directory) # Get the subdirectory listing. It should get     # two items GETLIST($list2,REMOTE_DIRECTORIES) FOREACH $subdirectory IN $list2 # Change current remote directory to that        # subdirectory  CHDIR($subdirectory) # Create the local subdirectory with the same name        # and change current local directory to it.        # LOCALMKDIR may fail because it already exists  LOCALMKDIR($subdirectory)  LOCALCHDIR($subdirectory) # Get the file listing  GETLIST($list3,REMOTE_FILES)  FOREACH $file IN $list3 # Download the file  $result=GETFILE($file)     # write the file to the log inside of that directory.      EXEC("echo D:\Messages\vmsg\".$subdirectory."\".$file." >> D:\Messages\vmsg\".$subdirectory."\".$subdirectory."-logfile.txt")     # If the file has been succesfully downloaded            # delete the remote copy. If not stop the script.  IF($result=="OK")  DELETEFILE($file)  ELSE  STOP  END IF  END FOREACH # Return to parent directory  CHDIR("..")  LOCALCHDIR("..") END FOREACH # Return to parent directory CHDIR("..") LOCALCHDIR("..") END FOREACH
Hi,

I think that Outlook or Outlook express cannot be used to send emails from the command line, at least without requiring interact with the user.

Using telnet to send emails is probably very easy to set up. But if you want to attach files it becomes far more complex as it requires you to encode the attached files and send it through the telnet channel.

The easiest way is to download and install blat ( http://sourceforge.net/projects/blat/files/ ) and configure it to send the emails with an attached file. For example:
Code: Select all# The blat command for sending an email # looks like this (without the line breaks): # # C:\blat\blat.exe # -server smtp.myserver.com # -u myuser_at_myserver.com # -pw mypassword # -f scriptftp@myserver.com # -to me@myserver # -subject "ScriptFTP error message" # -body "Error messsage here" # -ps "C:\path_to\my_atttached_file.zip" # $cmd_line_part_1=$blat_path." -server ".$smtp_server." -u ".$smtp_user." -pw " $cmd_line_part_2=$smtp_password." -f ".$email_from." -to ".$email_to." -subject ".'"' $cmd_line_part_3=$email_subject.'"' $cmd_line_part_4=" -body ".'"'.$email_body1.'"'." -ps ".'"'.$log_file_path.'"' # Concatenate the text strings to build the complete commands $cmd_line=$cmd_line_part_1.$cmd_line_part_2.$cmd_line_part_3.$cmd_line_part_4 # Launch blat EXEC($cmd_line)
Thanks.

I have not had the chance to test this. To much suprise my company is closing down. I'll have to give this a whirl once I land on my feet.

I appreciate your time.
Good luck mobo. If you have any other questions feel free to write here.