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
74 stars 26 forks source link

send csv file but failed #17

Closed FehnrirX closed 3 years ago

FehnrirX commented 3 years ago

please help.

i want to send csv file from spiffs with this path

String fileName = todayDate + ".csv"; String path = "/Data Absensi/" + todayDate + ".csv";

so i will send different csv every day, but it keep giving me error when i compile it

EMailSender::FileDescriptior fileDescriptor[1];
fileDescriptor[0].filename = F(fileName);
fileDescriptor[0].url = F(path);
fileDescriptor[0].storageType = EMailSender::EMAIL_STORAGE_TYPE_SPIFFS;
fileDescriptor[0].mime = MIME_TEXT_PLAIN;

error is

In file included from C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/Arduino.h:286, from C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/FS.h:25, from D:\Project\Arduino\curt2\webserver_email\webserver_email.ino:2: D:\Project\Arduino\curt2\webserver_email\webserver_email.ino: In function 'void sendToEmail()': webserver_email:612:36: error: initializer fails to determine size of 'pstr' 612 | fileDescriptor[0].filename = F(fileName); C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/WString.h:39:76: note: in definition of macro 'FPSTR' 39 | #define FPSTR(pstr_pointer) (reinterpret_cast<const FlashStringHelper *>(pstr_pointer)) | ^~~~ D:\Project\Arduino\curt2\webserver_email\webserver_email.ino:612:34: note: in expansion of macro 'F' 612 | fileDescriptor[0].filename = F(fileName); | ^ webserver_email:612:36: error: array must be initialized with a brace-enclosed initializer 612 | fileDescriptor[0].filename = F(fileName); C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/WString.h:39:76: note: in definition of macro 'FPSTR' 39 | #define FPSTR(pstr_pointer) (reinterpret_cast<const FlashStringHelper >(pstr_pointer)) | ^~~~ D:\Project\Arduino\curt2\webserver_email\webserver_email.ino:612:34: note: in expansion of macro 'F' 612 | fileDescriptor[0].filename = F(fileName); | ^ webserver_email:613:31: error: initializer fails to determine size of 'pstr' 613 | fileDescriptor[0].url = F(path); C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/WString.h:39:76: note: in definition of macro 'FPSTR' 39 | #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper >(pstr_pointer)) | ^~~~ D:\Project\Arduino\curt2\webserver_email\webserver_email.ino:613:29: note: in expansion of macro 'F' 613 | fileDescriptor[0].url = F(path); | ^ webserver_email:613:31: error: array must be initialized with a brace-enclosed initializer 613 | fileDescriptor[0].url = F(path); C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\cores\esp8266/WString.h:39:76: note: in definition of macro 'FPSTR' 39 | #define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer)) | ^~~~ D:\Project\Arduino\curt2\webserver_email\webserver_email.ino:613:29: note: in expansion of macro 'F' 613 | fileDescriptor[0].url = F(path); | ^ Multiple libraries were found for "SD.h" Used: C:\Users\User\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\SD Not used: C:\Program Files (x86)\Arduino\libraries\SD exit status 1 initializer fails to determine size of 'pstr'

what should i do?

xreef commented 3 years ago

Hi FehnrirX, you must remove F at this line fileDescriptor[0].url = F(path); . Bye Renzo

FehnrirX commented 3 years ago

Hi Renzo

Thanks for the respond. but now i get new issue

fileDescriptor[0].filename = fileName; fileDescriptor[0].url = path;

already check the contain of path and fileName, but serial show like this

Serial port read

any suggestion?

xreef commented 3 years ago

Hi FehnrirX, SPIFFS have some limitation (and directories were emulated not real), I think you don't use filename compliant. Try to open It on a simple sketch. You can find information here.

Bye Renzo

FehnrirX commented 3 years ago

image

here's what it looks like. already match with the contain of the path

xreef commented 3 years ago

Hi, put the complete code on the forum and I'm going to debug. https://www.mischianti.org/forums/forum/yours-project/

Bye Renzo

xreef commented 3 years ago

Solution found here.