xreef / EMailSender

Arduino, esp32, Esp8266 EMailSender with Arduino IDE, simple library to send email via smtp with attachments.
https://www.mischianti.org/category/my-libraries/emailsender-send-email-with-attachments/
MIT License
75 stars 28 forks source link

EMailSenderEsp32GMailSPIFFSAttachTest.ino #22

Closed froussel closed 2 years ago

froussel commented 2 years ago

Hello, In this example that works fine, just a warning: In file included from C:\Users\admin\Desktop\arduino-1.8.18\portable\sketchbook\__sources\esp32 s2\avecEmailsenderSpiffs2\avecEmailsenderSpiffs2.ino:17: In file included from C:\Users\admin\Desktop\arduino-1.8.18\portable\sketchbook\__sources\esp32 s2\avecEmailsenderSpiffs2\avecEmailsenderSpiffs2.ino:17: Infile included from C:\Users\admin\Desktop\arduino-1.8.18\portable\sketchbook\__sources\esp32 s2\avecEmailsenderSpiffs2\avecEmailsenderSpiffs2.ino:17: C:\Users\admin\Desktop\arduino-1.8.18\portable\sketchbook\libraries\EMailSender/EMailSender.h:222: warning: "EMAIL_NETWORK_CLASS" redefined #define EMAIL_NETWORK_CLASS EMAIL_NETWORK_SSL_CLASS' #define EMAIL_NETWORK_CLASS EMAIL_NETWORK_SSL_CLASS

In file included from C:\Users\admin\Desktop\arduino-1.8.18\portable\sketchbook\__sources\esp32 s2\avecEmailsenderSpiffs2\avecEmailsenderSpiffs2.ino:17: C:\Users\admin\Desktop\arduino-1.8.18\portable\sketchbook\libraries\EMailSender/EMailSender.h:165: note: this is the location of the previous definition #define EMAIL_NETWORK_CLASS WiFiClient `

if I replace the following part :

EMailSender::EMailMessage message; message.subject = "Fichier "; message.message = "Utilisation ";

EMailSender::FileDescriptior fileDescriptor[3]; fileDescriptor[2].filename = F("parcours36.gpx"); fileDescriptor[2].url = F("/parcours36.gpx"); fileDescriptor[2].storageType = EMailSender::EMAIL_STORAGE_TYPE_SPIFFS; fileDescriptor[2].mime = MIME_TEXT_PLAIN;

fileDescriptor[1].filename = F("test.txt");
fileDescriptor[1].url = F("/test.txt");
fileDescriptor[1].storageType = EMailSender::EMAIL_STORAGE_TYPE_SPIFFS;
fileDescriptor[1].mime = MIME_TEXT_PLAIN;

fileDescriptor[0].filename = F("logo.jpg");
fileDescriptor[0].url = F("/logo.jpg");
fileDescriptor[0].mime = "image/jpg";
fileDescriptor[0].encode64 = true;
fileDescriptor[0].storageType = EMailSender::EMAIL_STORAGE_TYPE_SPIFFS;

EMailSender::Attachments attachs = {3, fileDescriptor};`

by this one: compilation without problem, sending the email BUT no attached files

byte nb=3; EMailSender::EMailMessage message; message.subject = "3 Fichiers gpx"; message.message = "Utilisation de MyTracker "; EMailSender::FileDescriptior fileDescriptor[nb]; byte boucle=3; String nomfichier; while ( boucle > 0){ nomfichier = String( "parcours" + String(boucle) + ".gpx"); char __dataFileName[sizeof(nomfichier)]; nomfichier.toCharArray(__dataFileName, sizeof(__dataFileName)); fileDescriptor[boucle].filename = F(__dataFileName); nomfichier = String( "/" + nomfichier ); __dataFileName[sizeof(nomfichier)]; nomfichier.toCharArray(__dataFileName, sizeof(__dataFileName)); fileDescriptor[boucle].url = F(__dataFileName); fileDescriptor[boucle].storageType = EMailSender::EMAIL_STORAGE_TYPE_SPIFFS; fileDescriptor[boucle].mime = MIME_TEXT_PLAIN; Serial.print(" nomfichier : "); Serial.print(nomfichier); Serial.print(" boucle : "); Serial.println(boucle ); boucle -- ; }

EMailSender::Attachments attachs = {boucle, fileDescriptor};

xreef commented 2 years ago

The warning It's known, but It's an excellent compromise to simplify the usage. ;) Bye Renzo