This allows you to send email from your 4GL program. This module is also required if you wish to use ’REPORT TO EMAIL’ from within your 4GL application.
13.7.1 Dependancies
A patched libsmtp - http://libsmtp.berlios.de.
13.7.2 Function list
Displays the specified message and exits the program
set_errmsg(lv_msg)
Clears down any active smtp error message/error number
clear_err()
Sets the name of the smtp server to use.
set_server(lv_server)
Gets the name of the smtp server to use. If no server has been specified via the set_server function, then the SMTP_SERVER environment variable will be used instead. If no SMTP_SERVER is specified, ’mail’ is used.
get_server()
Returns the last generated error message.
get_errmsg()
Start a new message session.
start_message(lv_sender,lv_subject)
Add a recipient to a message session.
add_recipient(lv_message,lv_to)
Add a mime section to a message
mime_type_new(lv_message,lv_part,lv_mimetype)
mime_type_new_with_description(lv_message,
lv_part,lv_mimetype,lv_description)
Normally - if you are using a mime email, you would add two initial sections a mixed part and a text part. You then add any files to the mixed part. Eg:
let lv_mixedpart
= fgl_smtp::mime_type_new(lv_message,0,"multipart/mixed")
let lv_textpart
= fgl_smtp::mime_type_new(lv_message,lv_mixedpart,"text/plain")
if lv_rep_filename matches "*.pdf" or lv_hint="PDF" then
let lv_pdfpart
=fgl_smtp::mime_type_new_with_description(lv_message,
lv_mixedpart,"application/pdf",lv_rep_filename)
else
let lv_reppart
=fgl_smtp::mime_type_new_with_description(
lv_message,lv_mixedpart,"text/html",lv_rep_filename)
end if
Connect to an smtp server with a given message to send, if no server is specified (ie its null or blank) then the server from get_server will be used.
connect(lv_message,lv_server,lv_port,lv_flags,lv_ismime)
Closes the connection to the server and indicates that the email is complete and ready for transmision.
disconnect(lv_message)
Add additional recipients to an email message. the ’send_to’ is identical to the ’add_recipient’ function.
send_to(lv_message,lv_to)
send_to_cc(lv_message,lv_to)
send_to_bcc(lv_message,lv_to)
This is called to actually send the mime encoding of the file. the order in which these are used must match the order of the mime_type_new sections created previously.
part_send_file_html_listing(lv_message,lv_file,lv_last)
part_send_file(lv_message,lv_file,lv_last)
This is used by the 4GL library to send a report output (via the REPORT TO EMAIL) to the report recipients.
send_report(lv_hint,lv_rep_filename,lv_email_addr)