how to send Alert and avoid doing it second time (loop)?

some snippet to give you the idea

boolean prevState;;
boolean alarm = false;

uint32_t lastSMS  = 0;

void setup()
{
....
  prevState= getElectricityStateOK();  // init
}

void loop()
{
   boolean stateOK = getElectricityStateOK(); // you know how to do that

   if (stateOK  !=  True)  // there is an alarm state
  {
    if (millis() - lastSMS  > threshold)  sendSMS();      // send an SMS every threshold milliseconds.
    lastSMS = millis();

    if (prevState != stateOK)   // has state changed since last time?
    {
        alarm = true;
        ... do additional things when alarm goes of here (only one)
    }
   ... do things here while in alarm state ... every loop...

  }
  else
  {
    // reset the alarm 
     alarm = false;  
  }
  prevState = stateOK ; // remember the last state


  // rest of the program
  ...
  if (alarm) digitalWrite(LED, HIGH);
  else digitalWrite(LED, LOW);
  ...
}