| |
NOTE - Use your Browsers BACK Button to return to prior page.
OR Click either FUNCTIONS or TECHNIQUES
to return to that MENU.
Sending EMail in the Windows
95/98/NT Environment (using BLAT) |
|
Most information on sending eMail thru SQR seems to be in the Unix
environment. I did some research yesterday and finally found a pretty nice command line
send utility for Windows. It's a FreeWare product called BLAT. On this page you'll find
how to obtain BLAT, a demo SQR and Mail/BLAT API routines (SQC)... ...PLUS an elephant and
a camel. |
The one thing I really like about BLAT is that it's a no-frills product. There is no
fancy GUI interface to mess around with... it's strictly a command-line utility...
the installation instructions are very simple... and it seems to work very well with
SQR in the Windows environment... one more thing - it's FREE!
Because BLAT was an open-source product it has been developed by a group of people.
See the sites below for more information including history, download, credits, usage, etc.
Also note, no parties assume responsibility for the use of this software. For that matter
I also assume no responsibility or liability for any of the material on this site. As is
the
case with all FreeWare - use at your own risk!
See http://gepasi.dbs.aber.ac.uk/softw/Blat.html
OR http://www.interlog.com/~tcharron/blat.html
User Prompts for TDMAIL.SQR Demo
Program |
| Enter Subject Line: |
(or ENTER)... Default subject = 'TDMAIL
Test'.
| Enter Organization: |
(or ENTER)... This is OPTIONAL.
| Enter Recipient Address <or ENTER to break>: |
Builds comma-delimited Recipient List (one
address at a time)... REQUIRED.
| Enter CC Address <or ENTER to break>: |
Builds comma-delimited CC List (one address
at a time)... OPTIONAL.
| Enter BCC Address <or ENTER to break>: |
Builds comma-delimited BCC List (one address
at a time)... OPTIONAL.
| Enter TDMAIL (SQR/SQC) directory (i.e. c:\sqr\): |
Enter directory where you placed TDMAIL.SQR
/ TDMAIL.SQC
(Since the DEMO sends these as multiple
attachments).
TDMAIL.SQR - DEMO Program Source
code |
!**********************************************************************
!* *
!* MODULE: TDMAIL.SQR *
!* AUTHOR: TONY DELIA. *
!* DATE: 02/07/2001. *
!* SYSTEM: TD SQR UTILITY SERIES. *
!* DESC: DEMO - SEND E-MAIL (FROM WINDOWS USING "BLAT"). *
!* *
!**********************************************************************
!* *
!* NOTE: This demo will send TDMAIL.SQR and TDMAIL.SQC as *
!* multiple attachments. A message text file is also *
!* produced and sent as the body of the message. *
!* *
!* To successfully execute this demo you will need to *
!* obtain and install the freeware software "BLAT". *
!* See TDMAIL.SQC for details. *
!* *
!**********************************************************************
!* *
!* PROMPTS: Subject Line. *
!* Organization. *
!* Recipient List (one at a time) REQUIRED *
!* CC List (one at a time) *
!* BCC List (one at a time) *
!* Directory where TDMAIL (SQR/SQC) resides. REQUIRED *
!* *
!**********************************************************************
!* *
!* LEGAL: CONFIDENTIALITY INFORMATION. *
!* *
!* This module is the original work of Tony DeLia. It *
!* can be considered ShareWare under the following *
!* conditions. *
!* *
!* A - The author's name (Tony DeLia) remains on any *
!* and all versions of this module. *
!* B - Any modifications must be clearly identified. *
!* C - A "vanilla" copy of this module must be kept *
!* alongside any revised versions. *
!* *
!**********************************************************************
!* *
!* WEBSITE: http://www.sqrtools.com *
!* *
!* Questions/Comments: tdelia@erols.com *
!* *
!**********************************************************************
!**********************************************************************
!* Mainline Processing *
!**********************************************************************
begin-report
do Set-Defaults
do Build-Message
do User-Prompts
do Process-Main
end-report
!**********************************************************************
!* Set Defaults *
!**********************************************************************
begin-procedure Set-Defaults
let $ReportId = 'TDMAIL'
let $ReportTitle = 'SEND EMAIL USING BLAT'
display $ReportId noline
display ' ' noline
display $ReportTitle
display ' '
end-procedure
!**********************************************************************
!* Process Main *
!**********************************************************************
begin-procedure Process-Main
do MAIL-Func-Init()
do MAIL-Func-Parm('SUBJECT', $RC_subject)
do MAIL-Func-Parm('RECIPIENT', $RC_to)
do MAIL-Func-Parm('ORGANIZATION', $RC_org)
do MAIL-Func-Parm('CC', $RC_cc)
do MAIL-Func-Parm('BCC', $RC_bcc)
do MAIL-Func-Parm('ATTACH', $RC_sqr)
do MAIL-Func-Parm('ATTACH', $RC_sqc)
do MAIL-Func-Info()
do MAIL-Func-Send($O_file, #BLAT_status)
show 'Status: ' #BLAT_status
end-procedure
!**********************************************************************
!* User Prompts *
!**********************************************************************
begin-procedure User-Prompts
let $RC_to = ''
let $RC_subject = ''
let $RC_org = ''
let $RC_cc = ''
let $RC_bcc = ''
let $RC_dir = ''
let $RC_sqr = ''
let $RC_sqc = ''
input $RC_subject 'Enter Subject Line'
if $RC_subject = ''
let $RC_subject = 'TDMAIL Test'
end-if
input $RC_org 'Enter Organization'
do Enter-List('TO', $RC_to)
do Enter-List('CC', $RC_cc)
do Enter-List('BCC', $RC_bcc)
! Enter directory where TDMAIL.SQR/TDMAIL.SQC resides
while $RC_dir = ''
input $RC_dir 'Enter TDMAIL (SQR/SQC) directory (i.e. c:\sqr\)'
end-while
let #len = length($RC_dir)
if substr($RC_dir, #len, 1) <> '\'
let $RC_dir = $RC_dir || '\'
end-if
let $RC_sqr = $RC_dir || 'tdmail.sqr'
let $RC_sqc = $RC_dir || 'tdmail.sqc'
end-procedure
!**********************************************************************
!* Enter List (One Entry at a time) *
!**********************************************************************
!* This routine builds a comma-delimited list (no validation). *
!**********************************************************************
begin-procedure Enter-List($I_type, :$O_list)
let $O_list = ''
let $c = ''
while 1 = 1
evaluate $I_type
when = 'TO'
input $addr 'Enter Recipient Address <or ENTER to break>'
when = 'CC'
input $addr 'Enter CC Address <or ENTER to break>'
when = 'BCC'
input $addr 'Enter BCC Address <or ENTER to break>'
when-other
input $addr 'Enter eMail Address <or ENTER to break>'
end-evaluate
if $addr = ''
break
end-if
let $O_list = $O_list || $c || $addr
let $c = ','
end-while
end-procedure
!**********************************************************************
!* Build Message *
!**********************************************************************
begin-procedure Build-Message
let #O_no = 1
let $O_file = 'c:\temp\tdmail.txt'
open $O_file as #O_no for-writing record=1024:vary status=#O_stat
if #O_stat <> 0
show ' '
show 'Output file Error: ' $O_file
show ' '
stop
end-if
! Build Sample E-Mail Message
let $L01 = 'This is a test email message sent thru SQRW.'
let $L02 = 'It uses a freeware product called BLAT to send'
let $L03 = 'a message as well as attachments.'
let $L04 = 'The custom function library TDMAIL.SQC contains the'
let $L05 = 'necessary routines plus information on obtaining'
let $L06 = 'a copy of the BLAT executable and support files.'
let $L07 = 'I guess that does it... good luck...'
let $L08 = ' '
let $L09 = 'Regards,'
let $L10 = ' Tony DeLia'
let $L11 = ' '
let $L12 = 'PS - Please take a moment to fill out this survey: '
let $L13 = ' '
let $L14 = 'Place an X next to all applicable items.'
let $L15 = ' '
let $L16 = '___ This test failed miserably.'
let $L17 = '___ I received this email.'
let $L18 = '___ I received the attachment TDMAIL.SQR'
let $L19 = '___ I received the attachment TDMAIL.SQC'
let $L20 = '___ I am very impressed by all this.'
let $L21 = ' '
write #O_no from $L01
write #O_no from $L02
write #O_no from $L03
write #O_no from $L04
write #O_no from $L05
write #O_no from $L06
write #O_no from $L07
write #O_no from $L08
write #O_no from $L09
write #O_no from $L10
write #O_no from $L11
write #O_no from $L12
write #O_no from $L13
write #O_no from $L14
write #O_no from $L15
write #O_no from $L16
write #O_no from $L17
write #O_no from $L18
write #O_no from $L19
write #O_no from $L20
write #O_no from $L21
close #O_no
end-procedure
!**********************************************************************
!* Include Members: *
!**********************************************************************
#Include 'tdmail.sqc' !SQR Mail Send Functions (using BLAT)
!**********************************************************************
!* End of Program *
!**********************************************************************
|
TDMAIL.SQC - Send Mail API (using
BLAT) |
!**********************************************************************
!* *
!* MODULE: TDMAIL.SQC *
!* AUTHOR: TONY DELIA. *
!* DATE: 02/07/2001. *
!* SYSTEM: TD SQR UTILITY SERIES. *
!* DESC: SEND E-MAIL USING BLAT. *
!* *
!**********************************************************************
!* *
!* LEGAL: CONFIDENTIALITY INFORMATION. *
!* *
!* This module is the original work of Tony DeLia. It *
!* can be considered ShareWare under the following *
!* conditions. *
!* *
!* A - The author's name (Tony DeLia) remains on any *
!* and all versions of this module. *
!* B - Any modifications must be clearly identified. *
!* C - A "vanilla" copy of this module must be kept *
!* alongside any revised versions. *
!* *
!**********************************************************************
!* *
!* WEBSITE: http://www.sqrtools.com *
!* *
!* Questions/Comments: tdelia@erols.com *
!* *
!**********************************************************************
!**********************************************************************
!* Build MAIL Array *
!**********************************************************************
!* *
!* See MAIL-Func-Init for Initialization. *
!* See MAIL-Func-Parm for Parm Assignment. *
!* See MAIL-Func-Send for Send Mail. *
!* See MAIL-Func-Info for Parm Display. *
!* *
!**********************************************************************
!* *
!* BLAT: The following SQR procedures send email using a *
!* FreeWare Product called BLAT. It is ideal for *
!* sending command-line email messages/attachments *
!* from the Windows environment. *
!* *
!* These routines were tested using Blat 1.8.2b *
!* You can download this version at: *
!* *
!* http://gepasi.dbs.aber.ac.uk/softw/Blat.html *
!* *
!* You can also find information on BLAT at: *
!* *
!* http://www.interlog.com/~tcharron/blat.html *
!* *
!**********************************************************************
!* *
!* EXAMPLE: #define MAIL_path c:\winnt\system32\ *
!* ... *
!* do MAIL-Func-Init() *
!* ... *
!* do MAIL-Func-Parm('RECIPIENT', 'tdelia@erols.com') *
!* do MAIL-Func-Parm('SUBJECT', 'MAIL Test') *
!* do MAIL-Func-Parm('ORGANIZATION','ABC Company') *
!* do MAIL-Func-Parm('CC', 'jsmith@abc.com') *
!* do MAIL-Func-Parm('BCC', 'tjones@xyz.com') *
!* do MAIL-Func-Parm('FROM', 'fake@alias.com') *
!* do MAIL-Func-Parm('ATTACH', 'c:\temp\joke.txt') *
!* do MAIL-Func-Parm('-noh', ' ') *
!* ... *
!* do MAIL-Func-Send('c:\temp\msg.txt', #M_stat) *
!* ... *
!* if #M_stat <> 0 *
!* do MAIL-Func-Info() *
!* end-if *
!* *
!**********************************************************************
!* *
!* NOTES: Use the MAIL_path substitution variable to point *
!* to your directory containing BLAT.EXE. *
!* c:\windows\system\ is the default location. *
!* *
!**********************************************************************
!* *
!* USAGE: Below are flags, synonyms and descriptions. *
!* See BLAT Documentation for furthur details including *
!* installation procedure. *
!* *
!* FLAG SYNONYM(S) DESCRIPTION *
!* --------- ------------ ---------------------------------- *
!* -t RECIPIENT Recipient List (comma seperated). *
!* -t TO Same as 'recipient'. *
!* -s SUBJECT Subject Line. *
!* -o ORGANIZATION Organization. *
!* -o ORG Same as 'organization'. *
!* -c CC Copy List (comma seperated). *
!* -b BCC Blind Copy List (comma seperated). *
!* -f SENDER Sender Override (known to server). *
!* -i FROM From Override (any address here). *
!* -hostname HOSTNAME Hostname. *
!* -hostname HOST Same as 'hostname'. *
!* -attach ATTACH Binary File Attachment. *
!* -attach BINARY Same as 'attach'. *
!* -attacht ATTACHT Text File Attachment. *
!* -attacht TEXT Same as 'attacht'. *
!* -noh NOH Suppress BLAT URL in X-Mailer. *
!* -noh2 NOH2 Suppress Everything in X-Mailer. *
!* -server SERVER Mail Server. *
!* -port PORT Port. *
!* -mime MIME MIME. *
!* -uuencode UUENCODE UUENCODE. *
!* -base64 BASE64 BASE64. *
!* --------- ------------ ---------------------------------- *
!* *
!**********************************************************************
!**********************************************************************
!* MAIL-Array *
!**********************************************************************
begin-procedure MAIL-Array
#define MAILsize 30
create-array name=MAILmtx size={MAILsize} field=MAILflag:char -
field=MAILparm:char
let #MAILmax = {MAILsize} - 1
let #MAILctr = 0
end-procedure
!**********************************************************************
!* MAIL-Func-Init - Initialize MAIL Parms *
!**********************************************************************
!* *
!* INPUT: n/a - No input parameters *
!* OUTPUT: n/a - No output parameters *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See MAIL-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure MAIL-Func-Init()
clear-array name=MAILmtx
let #_MAILctr = 0
end-procedure
!**********************************************************************
!* MAIL-Func-Parm - Load MAIL Parameters *
!**********************************************************************
!* *
!* INPUT: $I_flag - MAIL Flag *
!* $I_parm - MAIL Parameter *
!* OUTPUT: n/a - No output parameters *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See MAIL-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure MAIL-Func-Parm($I_flag, $I_parm)
if #_MAILmax = 0
do MAIL-Array
end-if
let $I_flag = rtrim($I_flag,' ')
let $I_parm = rtrim($I_parm,' ')
! Convert Synonyms to BLAT Flags
if substr($I_flag,1,1) <> '-'
uppercase $I_flag
evaluate $I_flag
when = 'TO'
when = 'RECIPIENT'
let $I_flag = '-t'
when = 'SUBJECT'
let $I_flag = '-s'
when = 'ORG'
when = 'ORGANIZATION'
let $I_flag = '-o'
when = 'CC'
let $I_flag = '-c'
when = 'BCC'
let $I_flag = '-b'
when = 'SENDER'
let $I_flag = '-f'
when = 'FROM'
let $I_flag = '-i'
when = 'HOST'
when = 'HOSTNAME'
let $I_flag = '-hostname'
when = 'TEXT'
let $I_flag = '-attacht'
when = 'BINARY'
let $I_flag = '-attach'
when = 'ATTACH'
when = 'ATTACHT'
when = 'NOH'
when = 'NOH2'
when = 'SERVER'
when = 'PORT'
when = 'MIME'
when = 'UUENCODE'
when = 'BASE64'
let $I_flag = '-' || lower($I_flag)
when-other
! Invalid Synonym - Reject
let $I_flag = ''
let $I_parm = ''
end-evaluate
else
lowercase $I_flag
end-if
if $I_flag <> ''
if $I_flag = '-t'
let #idx = 0
else
if #_MAILctr = 0
let #_MAILctr = 1
end-if
let #idx = #_MAILctr
end-if
let MAILmtx.MAILflag(#idx) = $I_flag
let MAILmtx.MAILparm(#idx) = $I_parm
if #_MAILctr <= #idx
let #_MAILctr = #idx + 1
end-if
end-if
end-procedure
!**********************************************************************
!* MAIL-Func-Send - Send Mail Message (via BLAT.EXE) *
!**********************************************************************
!* *
!* INPUT: $I_file - MAIL Message File *
!* OUTPUT: #O_stat - MAIL Send Status *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See MAIL-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure MAIL-Func-Send($I_file, :#O_stat)
#ifndef MAIL_path
#define MAIL_path c:\windows\system\
#endif
let #O_stat = -1
if #_MAILctr > 0
let $line = ''
let #idx = 0
while #idx < #_MAILctr
let $flag = MAILmtx.MAILflag (#idx)
let $parm = MAILmtx.MAILparm (#idx)
let $parm = rtrim($parm,' ')
! Enclose in Double-Quotes if embedded spaces exist
if instr($parm,' ',1) > 0
if $flag = '-s' ! Subject
or $flag = '-o' ! Organization
let $parm = '"' || $parm || '"'
end-if
end-if
! Ensure required parameters are present (if not ignore)
if $parm <> ''
or $flag = '-noh'
or $flag = '-noh2'
or $flag = '-mime'
or $flag = '-uuencode'
or $flag = '-base64'
let $line = $line || $flag || ' ' || $parm || ' '
end-if
let #idx = #idx + 1
end-while
if substr($line,1,2) = '-t'
let $command = '{MAIL_path}blat.exe ' ||
$I_file ||
' ' ||
$line
call system using $command #O_stat WAIT
if #O_stat <> 0
show ' '
show 'Error Sending Mail'
show '=================='
show ' Status: ' #O_stat
show 'Command: ' $command
show ' '
end-if
else
! No Recipient Error
let #O_stat = -2
end-if
end-if
end-procedure
!**********************************************************************
!* MAIL-Func-Info - Display Current MAIL Parameters *
!**********************************************************************
!* *
!* INPUT: n/a - No input parameters *
!* OUTPUT: n/a - No output parameters *
!* *
!**********************************************************************
!* *
!* EXAMPLE: See MAIL-Array procedure for examples. *
!* *
!**********************************************************************
begin-procedure MAIL-Func-Info()
let $HDR_flag = rpad('=', 15, '=')
let $HDR_parm = rpad('=', 63, '=')
show ' '
show 'MAIL Parameters (BLAT.EXE)'
show ' '
show $HDR_flag ' ' $HDR_parm
let #idx = 0
while #idx < #_MAILctr
let $flag = MAILmtx.MAILflag (#idx)
let $parm = MAILmtx.MAILparm (#idx)
let $flag = rpad($flag, 15, ' ')
show $flag ' ' $parm
let #idx = #idx + 1
end-while
show $HDR_flag ' ' $HDR_parm
show ' '
end-procedure
!**********************************************************************
!* End of Program *
!**********************************************************************
|
Portion of SQR.LOG (from
TDMAIL.SQR execution) |
MAIL Parameters (BLAT.EXE)
=============== =====================================
-t tdelia@erols.com,anyone@somewhere.com
-s SQRTOOLS Mail Send SQR/SQC (BLAT)
-o SQRTOOLS.COM
-c
-b
-attach c:\sqr\tdmail.sqr
-attach c:\sqr\tdmail.sqc
=============== =====================================
|
Download Demo Program and MAIL
API Functions |
|
I would appreciate any feedback you may have on this site.
Send mail to tdelia@erols.com or click on the
Octopus. |
|
Please report any technical difficulties you may encounter to the address
above OR click on the Octopus. Thanks. |
NOTE - Use your Browsers BACK Button to return to prior page.
Tony DeLia - Updated February 8, 2001
|