Multiple email addresses? How to lazarus / 31-LCL ---------------------------------------------------------------------- Przemyslav · 2019-01-23 01:00 Hello everybody. I have problem with my program. My program send emails with attachments to multiple email addresses. Emails I have in code -->  Mail.Receivers.Add... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Mail := TSendMail.Create;   try      Mail.Sender := '*************' <'*************'>;      Mail.Receivers.Add('firstemail@gmail.com');    Mail.Receivers.Add('secondemail@gmail.com');      Mail.Subject := 'Hello';      Mail.Message.Add('How are you');      Mail.Smtp.UserName := '*************';      Mail.Smtp.Password := '*************';      Mail.Smtp.Host := 'smtp.gmail.com';      Mail.Smtp.Port := '587';    //Mail.Smtp.SSL := True;      mail.Smtp.FullSSL:=false;      Mail.Smtp.TLS := True;      Mail.Send;      ShowMessage('SUCCESS :) ');    finally      Mail.Free;    end; But I would like to have Edit component where I could write multiple email addresses separated with for example comma or semicolon: firstemail@gmail.com; secondemail@gmail.com; ... Something like in attachment. But I don't now how to copy separated email addresses from Edit to section Mail.Receivers.Add in my code with comma or semicolon and send to these receivers. Thank you very much ---------------------------------------------------------------------- jamie · 2019-01-23 01:20 The most practice way would be to decompose the string. For example, Use the function POS which will return return the first ";" it finds this will give you an index. Use the "LeftStr" function or Copy to another string, this will be the first one in the list.. you then add it to your other list. Delete this string from the current composite string including the ";" and repeat the cycle if it comes to a point where POS does not find a ";" then test the final results of this string and use that one for the final.  it could be that you only enter one and POS will not find the ";" so at this point it is the final string. ----  Another way is to list a loop and control a string from the master until you hit the end of the master string or a ";" WorkString := ''; For I := 1 to Length(MasterString) do  Begin    If MasterString[ I ] <> ';' Then Workstring := Workstring+MasterString[ I ] else      If WorkString <> '' Then      begin        Mail.AddToMYList(WorkString);        WorkString := '';      End;  if WorkString <> '' Then Mail.AddToMyList(WorkString); I think you get the idea. P.S.  You can also use a TstringList and set the Linebreak character which would be ";" and if I understand that correctly it should beak the line up when you assign the test.. Stringlist.LineBreal := ';'; StringList.Assign(MasterString); now the Items should be separated, maybe ---------------------------------------------------------------------- Leledumbo · 2019-01-23 18:29 TSendMail.Receivers is a TStrings descendant, TStringList is also a TStrings descendant. TStringList can be set to use Delimiter (, or ;, you choose), preferably with StrictDelimiter to true but it depends on you as well whether you want to allow whitespaces or not, then just assign that delimiter separated long string of email addresses to DelimitedText property. You can then simply call TSendMail.Receivers.A ssign(ThatTStringListInstanceWhoseDelimitedTextPropertyYouJustAssign), done. ---------------------------------------------------------------------- Przemyslav · 2019-01-29 17:06 Because I'm so stupid I can't do this. I tried with my example e-mails: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i joe@gmail.com;fred@gmail.com;mary@gmail.com and delimiter but it's to hard for me Thanks you for your help. ....... I have to try this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Mail.Receivers.Add('to=dest1@host.com;dest2@host.com'); ---------------------------------------------------------------------- CCRDude · 2019-01-29 17:25 Using delimiters is not that complicated; here's the three important properties: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Mail.Receivers.StrictDelimiter := true;Mail.Receivers.Delimiter := ';';Mail.Receivers.DelimitedText := 'joe@gmail.com;fred@gmail.com;mary@gmail.com'; ---------------------------------------------------------------------- Przemyslav · 2019-01-29 17:32 OK, now I get this. I try to make list in txt file and import to String Thanks ---------------------------------------------------------------------- mangakissa · 2019-01-30 07:30 No, you don't. the mailadresses can be used as an variable. If you have an editbox with several adresses you can use this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Mail.Receivers.DelimitedText := Editbox.txt ---------------------------------------------------------------------- Leledumbo · 2019-02-04 10:37 Quote from: mangakissa on January 30, 2019, 08:30:29 amNo, you don't. the mailadresses can be used as an variable. If you have an editbox with several adresses you can use this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Mail.Receivers.DelimitedText := Editbox.txtAh, didn't realize DelimitedText is part of TStrings instead of TStringList.