MailRules - Scripts
 

Welcome to our Scripts page, a place to get ideas.

This page will grow as the product is used by more and more customers. So check back often!

Microsoft provide a free tool called Scriptit that can assist you in automating your business processes.

You can download Scriptit here: http://www.microsoft.com/TechNet/winnt/Winntas/tools/scriptit.asp

 Q1: Can MailRules use PGP Encryption?

 Q2: Can MailRules use FTP to transmit a file?

 Q3: Can MailRules run GUI based configuration tasks?

A1: Yes. By default, MailRules uses the industry standard Zip 2.0 encryption format. The Zip 2.0 encryption format, however, is not as secure as DES and the RSA public key formats used by programs such as PGP, and does not provide absolute protection against determined individuals with advanced cryptographic tools.

It is very easy to integrate PGP encryption with MailRules, but you are advised that there are currently severe U.S. government restrictions on the export of encryption technology and usage of this technology may not be legal in some states/countries. For more details see http:\\www.pgp.com

To enable MailRules to use PGP encryption, PGP needs to be installed on the machines that will be transmitting or receiving the files.

Two rules then need to be created - one for encrypting the file at source, the other for decrypting at reception. These rules call command (batch) files that handle the actual PGP encryption and decryption.

Example:-

The following example illustrates how file(s) in the directory E:\Out on the transmitting machine, can by encrypted and sent to the receiving machine, where it will be decrypted and saved into a directory called E:\In.

The Outbound Rule on the transmitting machine is set up as follows:

In this example, the outbound rule is set to send one file, secure.zip.pgp. A command to run before sending e-mail is set, this command is encrypt.cmd.

This command zips up the files in the E:\Out directory to an archive called secure.zip then uses PGP to encrypt this file, It is this encrypted file that is sent.

Encrypt.cmd

REM ** This command file generates a files called secure.zip.pgp **
REM ** Removes old zip file **
del E:\secure.zip
REM ** Compresses contents of E:\out dir to one file called secure.zip **
c:\pkzip\pkzip.exe e:\secure.zip e:\out\*.*
REM ** Encrypts file secure.zip using password "number1" **
pgp -c E:\secure.zip +force -znumber1

The Inbound rule on the receiving machine is set up as follows:

The Inbound rule is set to save attachments from email with the subject line Secure to the E:\IN directory. The decrypt.cmd command is then run, this command decrypts the encrypted file, which returns the original zip file secure.zip, this zip file is then unzipped into the E:\IN directory thus placing the original files into the new location.

Decrypt.cmd

E:
cd \in
REM **Decrypts the file secure.zip.pgp using a PGP password of "number1" **
pgp E:\in\secure.zip.pgp -p +force -znumber1

REM **Removes encrypted file **
del E:\in\secure.zip.pgp

REM **Unzips decryted file secure.zip which restores files as per the original sent files **
C:\PKZIP\PKUNZIP.EXE -o secure.zip

REM **Removes decrypted zip file **
del E:\IN\secure.zip

Back to top

A2: Yes. Upon receipt of an email MailRules can run an external command, typically a program or batch file. This can be used to transmit a received file using FTP.

In the example scenario a single file for FTP is transmitted as an attachment to a MailRules client. MailRules has an inbound rule configured as shown:

Receipt of a message with the subject "File to FTP" will cause the attachment to be saved to the directory C:\temp\FTP. Then the external command Part1.bat is executed. Part1.bat in turn calls part2.bat to determine the filename to be transferred via ftp. At the end of Part1.bat any files in C:\temp\ftp are deleted ready for the next file to be processed.

This procedure relies on Microsoft's command line ftp client which is included with Windows 95 and Windows NT.

Contents of Part1.bat

cd\
echo open cwdev > c:\ftpbatch.txt
echo anonymous>> c:\ftpbatch.txt
echo someone@somewhere.com>> c:\ftpbatch.txt
echo put>> c:\ftpbatch.txt
call c:\part2.bat
echo close >> c:\ftpbatch.txt
echo quit >> c:\ftpbatch.txt

ftp -s:c:\ftpbatch.txt
del c:\temp\ftp\*.* /Q

Contents of Part2.bat

cd \temp\ftp
dir /b >>c:\ftpbatch.txt
dir /b >>c:\ftpbatch.txt

ftpbatch.txt is created by the two batch files and does not exist by itself.

Back to top

A3: Yes, using Microsoft's Scriptit. MailRules can be configured to call a Scriptit script, which will in turn allow the GUI based configurations or tasks to be automated.
The following example shows how MailRules and Scriptit can be configured to open an access database then run a Compact and repair, when MailRules receives an E-mail with the subject line "Repair Database". MailRules is setup with the following Inbound Rule :-

This rule runs the following Scriptit Script ..

[Script]
run = "msaccess.exe C:\test\test.mdb"
Microsoft Access=!T
Microsoft Access={DOWN 4}
Microsoft Access={RIGHT 1}
Microsoft Access={DOWN 1}
Microsoft Access={ENTER}
Microsoft Access=!F
Microsoft Access={UP 1}
Microsoft Access={ENTER}

This script opens the Test access database then runs the 'Compact and Repair Utility' then closes the database.

Back to top