Blynk not sending an email

Hello, I’m using esp32, blynk iot, the error is ‘class blynkwifi’ has no member named ‘email’
This is the code:


#define BLYNK_TEMPLATE_ID ""
#define BLYNK_TEMPLATE_NAME "LED"
#define BLYNK_AUTH_TOKEN "
"

#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>

#define LED 2
//Adafruit_MPU6050 mpu;
int ledState;
int value;
// WiFi credentials
char ssid[] = "";
char pass[] = "";

// Blynk Authorization Token
char auth[] = BLYNK_AUTH_TOKEN; // Correctly declare the auth variable
BlynkTimer timer;
void setup(void) {
  Serial.begin(115200);
  pinMode(LED, OUTPUT);
  while (!Serial); // Wait for serial port to connect. Needed for native USB port only

  //Serial.println("Adafruit MPU6050 test!");

  //if (!mpu.begin()) {
    //Serial.println("Failed to find MPU6050 chip");
    //while (1) {
      //delay(10);
    //}
  //}
  //Serial.println("MPU6050 Found!");

  //mpu.setHighPassFilter(MPU6050_HIGHPASS_0_63_HZ);
  //mpu.setMotionDetectionThreshold(1);
  //mpu.setMotionDetectionDuration(20);
  //mpu.setInterruptPinLatch(true);
  //mpu.setInterruptPinPolarity(true);
  //mpu.setMotionInterrupt(true);

  Blynk.begin(auth, ssid, pass); // Use the auth variable to establish a connection to the Blynk server
}

void loop() {


  Blynk.run(); 
  timer.run(); // Initiates BlynkTimer
}

// Function to handle the button press
BLYNK_WRITE(V0) {
  int value = param.asInt();
  digitalWrite(LED, value); // Turn LED on or off based on button state
}

// Function to send email status
void sendEmailStatus() {
  int ledState = digitalRead(LED);
  Blynk.virtualWrite(V2, ledState);
  if (ledState == HIGH) {
    // Send email when LED is turned on
    Serial.println("Sending email: LED turned on");
    Blynk.email("", "LED Status", "The LED has been turned on.");
    Blynk.logEvent("LED", "LED is on");
  } 
  else {
    // Send email when LED is turned off
    Serial.println("Sending email: LED turned off");
    Blynk.email("", "LED Status", "The LED has been turned off.");
    Blynk.logEvent("LED", "LED is off");
  }
} 

The Blynk.email() is not supported in Blynk IoT
Emails are sent using the ‘log.Event()` process.

But, the code you’ve posted is incomplete, because there is currently no way to trigger the sendEmailStatus() and although you’ve declared a BlynkTimer object called timer and you have timer.run() in your void loop, you have no timed actions defined.

Pete.

So in this case, what should I change in my code to make it work?

It’s impossible to say without understanding what your code is meant to achieve.

Pete.

the code is supposed to send an email through esp32 when the led turns on or off, and i already have log.event in the code and it still not sending an email, the free version in blynk supposed to send email correct?

The LED is being turned on/off via a widget attached to datastream V0, which is presumably a switch widget, so in effect you’re sending a push notification and an email saying “Hey, you pushed the button”. What’s the sense in that?

Blynk has a limit of 100 log.Event actions per 24 hour period, so repeatedly pushing the button could easily result in this limit being exceeded in the first minute of operation.

That’s because the log.Egent command is never called, as I explained earlier…

Correct.

You should probably read this if you want to learn more about using log.Event in a sensible way…

Pete.

I know it doesn’t make sense, I’m using this code just to test out if it will send Email, the original code is supposed to detect a crash based on mpu6050, would you like me ti attach the original code here to check?
Thanks