Home › Forums › The libraries hosted on the site › EMailSender send email with attachments › Empty attachment
Tagged: EMail, Empty attachments
- This topic has 12 replies, 2 voices, and was last updated 4 years, 8 months ago by
Renzo Mischianti.
-
AuthorPosts
-
-
25 September 2020 at 22:06 #6495
Norbert
Hi,
Esp8266 Wemos D1 Mini, emailsender is working fine except attachment. It can attach the file with correct name/extension but if I want to open it it is always empty. No content.
80-90bytes in size on arrival but when I want to open a txt file attached it is empty. I tried to change mime type or encode 64 true/false but no change.
-
26 September 2020 at 20:49 #6497
Hi Norbert,
If the file It’s 80byte mean the there are almost 80 characters. It’s very strange, try to change extension, like xml or similar.
Please give me a feedback.
Bye Renzo
-
27 September 2020 at 09:32 #6507
Michael
Hey there,
i have the same exact problem….
Your Lib works very nice! But the attachments of the recieved e-mail are empty.
I also use the WEMOS D1Mini Pro Board with an SD Card (also tried Spiffs, but also blank attachments)
@Mischianti: Did your attachments work? (i’m asking because you mentioned in your article, that you’ve tested it on an Wemos D1 Mini)
I also tried using .xml .csv .pdf file extension with and without enabled encoding 64.
Have you any clue what could be the reason for these empty attachments? :/
Thanks a lot!
Greetings from Germany
-
27 September 2020 at 10:23 #6508
Hi Michael,
I tested now my WeMos D1 mini, and the txt attachment works correctly.
But It’s strange because if the file It’s 80byte mean that there are 80 character, so It isn’t empty.
Can you send me your code PLZ.
Bye Renzo
Attachments:
You must be logged in to view attached files. -
27 September 2020 at 11:05 #6510
Michael
Thanks for your quick response!
I took the example code, provided in your library and changed minor things….:
/* * EMailSender library for Arduino, esp8266 and esp32 * esp8266 Gmail send example with 2 attach loaded in SPIFFS * * The base64 encoding of the image is slow, so be patient * * http://mischianti.org/category/my-libraries/emailsender-send-email-with-attachments/ * */ #include "Arduino.h" #include
#include // Libraries for SD card #include "FS.h" #include "SD.h" uint8_t connection_state = 0; uint16_t reconnect_interval = 10000; EMailSender emailSend("XXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXX"); uint8_t WiFiConnect(const char *nSSID = nullptr, const char *nPassword = nullptr) { static uint16_t attempt = 0; Serial.print("Connecting to "); if (nSSID) { WiFi.begin(nSSID, nPassword); Serial.println(nSSID); } uint8_t i = 0; while(WiFi.status()!= WL_CONNECTED && i++ < 50 ) { delay(200); Serial.print(".");}++attempt; Serial.println(""); if (i == 51) { Serial.print("Connection: TIMEOUT on attempt: "); Serial.println(attempt); if (attempt % 2 == 0) Serial.println( "Check if access point available or SSID and Password\r\n"); return false; } Serial.println("Connection: ESTABLISHED"); Serial.print("Got IP address: "); Serial.println(WiFi.localIP()); return true; } void Awaits() { uint32_t ts = millis(); while (!connection_state) { delay(50); if(millis() > (ts + reconnect_interval) && !connection_state ) { connection_state = WiFiConnect(); ts = millis(); } } } void setup() { Serial.begin(9600); const char *ssid = "XXXXXXXXXXXXXXXXXXXXX"; const char *password = "XXXXXXXXXXXXXXXXXXXXX"; if (!SD.begin(15)) { Serial.println("An Error has occurred while mounting SD"); return; } Serial.println("SD OK"); /*Serial.println("ReadDir"); Dir dir = SPIFFS.openDir("/"); while (dir.next()) { Serial.print(dir.fileName()); if(dir.fileSize()) { File f = dir.openFile("r"); Serial.println(f.size()); } } */ connection_state = WiFiConnect(ssid, password); if (!connection_state) // if not connected to WIFI Awaits(); // constantly trying to connect Serial.println("CONNECTED"); EMailSender::EMailMessage message; message.subject = "XXXXXXXXXXXXXXXXXXXXX"; message.message = "XXXXXXXXXXXXXXXXXXXXX"; Serial.println("Point0"); EMailSender::FileDescriptior fileDescriptor[4]; fileDescriptor[0].filename = F("test.txt"); fileDescriptor[0].url = F("/test.txt"); fileDescriptor[1].mime = "text/plain"; fileDescriptor[0].storageType = EMailSender::EMAIL_STORAGE_TYPE_SD; Serial.println("Point1"); fileDescriptor[1].filename = F("test.pdf"); fileDescriptor[1].url = F("/test.pdf"); fileDescriptor[1].mime = "application/pdf"; fileDescriptor[1].encode64 = true; fileDescriptor[1].storageType = EMailSender::EMAIL_STORAGE_TYPE_SD; fileDescriptor[2].filename = F("test.xml"); fileDescriptor[2].url = F("/test.xml"); fileDescriptor[2].mime = "application/xml"; fileDescriptor[2].encode64 = true; fileDescriptor[2].storageType = EMailSender::EMAIL_STORAGE_TYPE_SD; fileDescriptor[3].filename = F("test.csv"); fileDescriptor[3].url = F("/test.csv"); fileDescriptor[3].mime = "text/csv"; fileDescriptor[3].encode64 = true; fileDescriptor[3].storageType = EMailSender::EMAIL_STORAGE_TYPE_SD; EMailSender::Attachments attachs = { 4, fileDescriptor }; Serial.println("Point2"); EMailSender::Response resp = emailSend.send( "XXXXXXXXXXXXXXXXXXXXX", message, attachs); Serial.println("Point3"); Serial.println("Sending status: "); Serial.println(resp.status); Serial.println(resp.code); Serial.println(resp.desc); } void loop() { } -
This reply was modified 1 year, 10 months ago by
Renzo Mischianti.
-
This reply was modified 1 year, 10 months ago by
-
27 September 2020 at 15:32 #6512
Hi Michael,
there is an error on index of txt file, so the mime type is not setfileDescriptor[0].filename = F("test.txt"); fileDescriptor[0].url = F("/test.txt"); fileDescriptor[1].mime = "text/plain"; fileDescriptor[0].storageType = EMailSender::EMAIL_STORAGE_TYPE_SD;
I rewrite the sketch and put some example, I test It with SPIFFS and work correctly
I attach the sketch with all sampe file.
Bye Renzo
Attachments:
You must be logged in to view attached files. -
27 September 2020 at 17:28 #6514
Norbert
I use spiffs by the way.
Outlook displays 80byte for the attachment, after saving to a folder it is 0 bytes in a file explorer.
-
27 September 2020 at 17:30 #6515
Try to send the attach via classic email from gmail or similar.
I think the problem is outlook.
-
27 September 2020 at 18:32 #6530
Norbert
You got it. I checked it on the web surface of gmail and the attachments have arrived correctly but not with outlook.
Do you have any idea what is the problem with outlook?
-
27 September 2020 at 19:01 #6531
I check on the web and seems there are a lot of problems with Outlook,
can you try to send the txt file directly from gmail and check in outlook?
Bye Renzo
-
27 September 2020 at 20:49 #6532
Hello together, i think i solved the Problem 🙂
Now all four tested file extensions work! (xml,pdf,txt,csv) there was an issue in your library:
in EMailSender.cpp Line 386:
Original:
client.println();
New:
client.println("\n");
Thanks for your help and great work!
I’m very happy, that it works now!
I put a Screenshot and the .cpp file below (had to rename it to .txt)
Attachments:
You must be logged in to view attached files. -
27 September 2020 at 21:15 #6534
Norbert
Yes it is working now.
Thank you for your help!
-
27 September 2020 at 21:54 #6535
Thanks to all,
I’m going to release a new library version with this fix and new distribution list features.
Thanks again Renzo
-
-
AuthorPosts
- You must be logged in to reply to this topic.