I had the same problem but when I changed parse with valueOf everything was fine. The passed date format was wrong.
Try this
couObj.Course_Date__c = Date.valueOf(temp_date);
So the main limitation you will find here is the amount of Heap Space required of transforming your CSV into a workable Apex Type to parse through. That said as long as the combination of Rows and Columns in your CSV doesn't exceed that limit, either approach is fine. I actually did this as an AppExchange app a while ago and used the first approach.
EDIT (in response to your comment)
So I guess the first thing is just make sure when you convert your attachment from a blob
to a string
that it is actually right. Here is a sample Inbound Email parser:
global class MyEmailHandler implements Messaging.InboundEmailHandler
{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope)
{
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
for(Messaging.InboundEmail.BinaryAttachment att : email.binaryAttachments)
{
if(att.fileName == 'testAtt.csv')
{
system.debug(att.body.toString());
}
}
return result;
}
}
Here is what my testAtt.csv
looks like:
foo,bar
Hello,World
And here is what my debug()
statement prints out:
|USER_DEBUG|[11]|DEBUG|foo,bar
hello,world
From there you should be able to take that string
and put it through any CSV parser to give you a two dimensional array to parse through.
Sidenote; here are the settings for my Email Service, note the "Convert Text Attachments to Binary Attachments":
Best Answer
We have implemented a REST API which allow to directly integrate Salesforce with SFTP Server. You can directly upload file from salesforce to SFTP Server using this REST API.
Here we are addng API documentation link. (Note: this link will never change)
FTP API: https://www.ftp-api.com/
Here we are adding upload example with code snippts.
#1. FTP_UploadFile.cmp
FTP_UploadFileController.js
FTP_UploadFileHelper.js
#2. FTPWebServiceCompCtrl.cls
#3. FTPWebServiceExample.cls
#4. FTPWebService.cls
#5. FTPWebServiceUtility.cls
#6. FTPResponseWrapper.cls
Here we are adding complete github repository link. (Note: repository link will never change) Link:https://github.com/ftprestapi/ftp-api-example