Saturday, 27 February 2021

Splits multiple email ids in to (List of Text) data type before sending an email notifications to someone through AL code.


EmailSplits('abc@gmail.com;xyz@gmail.com');

SmtpMail: Codeunit "SMTP Mail";
SmtpConf: Record "SMTP Mail Setup";
EmailBody: text;

SmtpMail.CreateMessage('Checking multiple Emails', SmtpConf."User ID", 
                        Receipt, 'Emails ', EmailBody, true);
        
    local procedure EmailSplits(EmaifieldValue: Text[250])
    var
        PosBgn: Integer;
        ValueLength: integer;
        PosEnd: Integer;
        SplitValue: Text;
    begin
        PosBgn := 1;
        ValueLength := STRLEN(EmaifieldValue);
        REPEAT
            IF STRPOS(EmaifieldValue, ';'0 THEN
                PosEnd := ValueLength
            ELSE
                PosEnd := (STRPOS(EmaifieldValue, ';'1);
            SplitValue := COPYSTR(EmaifieldValue, PosBgn, PosEnd);
            EmaifieldValue := DELSTR(EmaifieldValue, 1, PosEnd + 1);
            Receipt.Add(SplitValue);
        UNTIL EmaifieldValue = '';
    end;






No comments:

Post a Comment

Extension Unpublished/Uninstalled history required in BC Production environment

  There is a situation when someone can uninstall or unpublish any APP extension from the extension management in Production environment, th...