<< ibec_ShiftRecord | IBEBlock | ibec_WaitForEvent >>

ibec_smtp_SendMail

This function sends an email using SMTP protocol.

Syntax

    function ibec_smtp_SendMail(SMTPHost : string; SMTPPort : string; UserName : string;
                               Password : string; From : string; To : string; CC : string; BCC : string;
                               Subject : string; Message : string; AttachedFiles : string;
                               AdditionalHeaders : string; Options : string; CallbackBlock : string) : variant;

Options (still in work):

AuthTypeE.g. AuthType=NONE
PriorityHighest/High/Normal/Low/Lowest
... 
  ibec_smtp_SendMail(...,
                   'Encoding=windows-1251; Confirm; Priority=Highest; AuthType=NONE',
                    cbb);

See also the example below.

Example

execute ibeblock
as
begin
  CRLF = ibec_CRLF();
  cbb = 'execute ibeblock (Vals variant)
         as
         begin
           sPref = '''';
           sEvent = Vals[''EVENT''];
           if ((sEvent = ''COMMAND'') or (sEvent = ''HEADER'')) then
             sPref = ''==> '';
           else if (sEvent = ''RESPONSE'') then
             sPref = ''<== '';
           sMes = sPref + Vals[''TEXT''];
           ibec_Progress(sMes);
           LogFile = ibec_GetGlobalVar(''LogFileH'', null);
           if (LogFile is not NULL) then
             ibec_fs_Writeln(LogFile, sMes);
        end';

  sMessage = 'Just a test' + CRLF +
             'This message was sent by ibec_smtp_SendMail function';

  sAttachments = 'D:\smtpsendmail.ibeblock' + CRLF +
                 'D:\script.sql';

  sAddHeaders  = 'IBE-Type: IBEBlock' + CRLF +
                 'IBE-Comment: Just a comment';

  LogFile = ibec_fs_OpenFile('D:\smtp.log', __fmCreate);
  try
    if (LogFile is not null) then
      ibec_SetGlobalVar('LogFileH', LogFile);
    ibec_smtp_SendMail('mail.myserver.com',
                       'smtp',
                       'Bill',
                       'windows_must_die!',
                       '"Bill Gates" <Bill@microsoft.com>',
                       'all@world.com',
                       '',
                       '',
                       'Test message from IBEBlock ibec_smtp_SendMail function',
                       :sMessage,
                       :sAttachments,
                       :sAddHeaders,
                       'Encoding=windows-1251; Confirm; Priority=Highest',
                       cbb);
  finally
    ibec_fs_CloseFile(LogFile);
  end;
end

back to top of page
<< ibec_ShiftRecord | IBEBlock | ibec_WaitForEvent >>