Example: Send e-mail
Functions working with e-mail will not raise an exception and cannot be processed by a handle.
PROCEDURE SendMail();
BEGIN
DECLARE Letter, Err INT;
DECLARE CrLf CHAR(2) DEFAULT Chr(13)+Chr(10);
DECLARE Mail NCLOB;
SET Letter = 0;
SET Err = InitWBMail('sql602test', NULL);
IF Err = 0 THEN BEGIN
SET mail = 'Data from day '||Date2str(Today,1)||Crlf||'---------------------------'||CrLf;
SET Err = LetterCreate('Data', Dopis, 2+4, Letter);
END;
END IF;
IF Err = 0 THEN
SET Err = LetterAddAddr(Letter,'NTserver@software602.com','SMTP',FALSE);
END IF;
IF Err = 0 THEN
SET Err = LetterAddFile(Letter, 'c:\temp\data.tdt');
// SET Err = LetterAddFile(Letter, '/var/temp/data.tdt'); // on Linux
END IF;
IF Err = 0 THEN
BEGIN
SET Err = LetterSend(Letter);
SET Letter = 0;
END;
END IF;
IF Err <> 0 THEN
BEGIN
CALL Log_write('An error occurred while sending the e-mail '' + int2str(Err));
IF Letter <> 0 THEN
CALL LetterCancel(Letter);
END IF;
END;
END IF;
CALL CloseWBMail();
END