Community discussions

MikroTik App
 
User avatar
diamuxin
Member
Member
Topic Author
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Group content in email

Fri Feb 03, 2023 7:00 pm

Hi, one question, please:

On this loop
:foreach tagContent in=$smsList do={
  
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  :local phone [($tokenParser->"getTag") source=$tagContent tag="Phone"]
  :local content [($tokenParser->"getTag") source=$tagContent tag="Content"]
  :local read ([($tokenParser->"getTag") source=$tagContent tag="Smstat"] = 1)

  :if ($content != "") do={
  /tool e-mail send to=to@mail.com subject="SMS List" body="$index $read $phone $content"
  # :put "$index $read $phone $content"
  }

}

if I execute the ":put" I get this result:

[admin@Mikrotik] > sys scr run test-sms
40001 false +34XXXXXXXXX Lorem ipsum 2
40000 false +34XXXXXXXXX Lorem ipsum 1

If I execute the email, I get the following, i.e. it sends me an email for each line.

Email2:
SMS List
40001 false +34XXXXXXXXX Lorem ipsum 2

Email1:
SMS List
40000 false +34XXXXXXXXX Lorem ipsum 1

I would like to know how I can get the two lines (or three, four, etc) in a SINGLE email.

Single email:
SMS List
40001 false +34XXXXXXXXX Lorem ipsum 2
40000 false +34XXXXXXXXX Lorem ipsum 1

Is it possible? Thanks.

BR.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Group content in email

Fri Feb 03, 2023 7:09 pm

unverified code

:local sendthisuniquelist ""

:foreach tagContent in=$smsList do={
  
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  :local phone [($tokenParser->"getTag") source=$tagContent tag="Phone"]
  :local content [($tokenParser->"getTag") source=$tagContent tag="Content"]
  :local read ([($tokenParser->"getTag") source=$tagContent tag="Smstat"] = 1)

  :if ($content != "") do={
  # :put "$index $read $phone $content"
  :set sendthisuniquelist ($sendthisuniquelist."$index $read $phone $content\r\n")
  }

}

/tool e-mail send to=to@mail.com subject="SMS List" body=$sendthisuniquelist
 
User avatar
diamuxin
Member
Member
Topic Author
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Group content in email

Sun Feb 05, 2023 11:04 pm

It works correctly, thanks Rex.

BR.

Who is online

Users browsing this forum: No registered users and 22 guests