read CSV file on SD and send it by mail

Hi

Does somebody know how to read a file on a SD card and send it by mail.(file consist of 296lines

I have a PV logger and i write every 5min a new line in a file on the SD card and send it to a PV-site. (time,date, power, kwh, temperature …)
i also send a mail of the complete status end of the day. But sometimes the logging is incomplete on the PV-site
So than i want to get the file from the SD card . Now i remove the SD card and read it out from a PC .
But it would be easier that the complete file will be send by mail . is there a easy way

Did you try this: http://playground.arduino.cc/Code/Email That code checks the communication and returns an error if it failed.

Hi Peter

Mail is not a probleem, the site is more the probleem Sometimes, it does not give aan response( in time) or gives a server error, etc.... when i had sent the data, at that time. But also sometimes the site is down, for updates etc. So i prefer reading sd file and sent it by mail... Then i can update the site manuel

Your response is confusing. Does your Arduino send email ok using the code in the link Peter_n posted?

Like i posted in first, my arduino is sending a mail at the end of the day. That is already working in my code,so not from Peter_n. I sending also data to a site and SD, but this site is not always correct responding..

Then open the SD file and send the contents of that file as the email body. Since you did not post any code, neither will I.

edit: That is not quite true. I did post code, but not directly here. The link to the email code Peter_n posted is my email code in the playground.

this it my mail code

EthernetClient mailClient;

void SendMail()
{
    if(mailClient.connect(MAIL_SERVER,25))
    {
        if(CheckResponse())
        {
            mailClient << F("HELO Arduino") << endl; // say hello
            if(CheckResponse())
            {
                mailClient << F("MAIL FROM:" MAIL_FROM) << endl; // identify sender
                if(CheckResponse())
                {
                   mailClient << F("RCPT TO:" MAIL_TO) << endl; // identify recipient
                    if(CheckResponse())
                    {
                        mailClient << F("DATA") << endl;
                        if(CheckResponse())
                        {
                            mailClient << F("Subject:SolarMeter - daily report - day ") << day() << endl; 
                         
                            mailClient << F("Content-type: text/html;") << endl << endl;

                            ShowStatus(mailClient);

                            mailClient << endl << F(".") << endl; // end of mail

		            if(CheckResponse())
                            {
                                mailClient << F("QUIT") << endl; // terminate connection
                            }
                        }
                    }
                }
            }
        }
        mailClient.stop();
    }
}

opening a file is like
logFile = SD.open(fullName);

but i have to read character by character in a buffer, untill end of line.
.Then File logFile << F(buffer) ;
then go the next line etc etc untill end of file or someting like that ???

Here is where you send your file. It must be before the period on the line by itself.

                            mailClient << F("Content-type: text/html;") << endl << endl;

                            ShowStatus(mailClient);

                            mailClient << endl << F(".") << endl; // end of mail

The best way is read a line from the file and send that line, then read another line and send it, and so on, until the end of the file.

You mean every line is a separate mail ? The file will have 296 lines at the end of the day , then i will receive 296 mails , in this case. thats not a good idee !

i prefer only sending i mail , with the complete file. But is the problem than that i have to but the complete file in a buffer?

logger:
You mean every line is a separate mail ?
The file will have 296 lines at the end of the day , then i will receive 296 mails , in this case. thats not a good idee !

i prefer only sending i mail , with the complete file. But is the problem than that i have to but the complete file in a buffer?

No. You can send the file in one email. Just keep adding lines to the one email. It won’t terminate the email body until you send a period on a line by itself.

edit: Like this. All these lines are sent in one email.

                            mailClient << F("Content-type: text/html;") << endl << endl;
                            mailClient << F("This is line one") << endl;
                            mailClient << F("This is line two") << endl;
                            mailClient << F("This is line three") << endl;
                            mailClient << F("This is line four") << endl;

                            ShowStatus(mailClient);

                            // this tells the email server you are finished sending lines of the email body
                            mailClient << endl << F(".") << endl; // end of mail

Ok Thanks, now i understand more.. I will try to make a working code of it

rough it will be like.....

-open mail -open file -DO -read line in the buffer ,until end of line is reached - add the buffer to the mail -WHILE character in buffer !EOF -close file -close the mail

That looks like the way to do it!