+ Start a Discussion
marys pindamarys pinda 

Computer file to Salesforce

Is it possible to develop an Apex class that will take a file on my computer EVERY DAY and it will stored in Salesforce?
How do I do this?
Does anyone have any code for me to follow as a model?

Thank you,
Karan Khanna 6Karan Khanna 6

I dont think you can do that through Apex, why dont you go other way round, push the file from your desktop to Salesforce.

simplest way which I can think to achieve this would be:

1. Create inbound email service handler in salesforce to handle incoming mails (along with attachments). here you can find sample code:

2. Create a task on your desktop through Control panel for sending that file to salesforce email service handler address through mail.
Open Task Scheduler by clicking the Start button   , clicking “Control Panel”, clicking “System and Security”, clicking “Administrative Tools”.

marys pindamarys pinda
Thank you...

The Apex is not able to manipulate a file from my computer and send to the Salesforce platform?
marys pindamarys pinda
I managed to make a code to send any file to Salesforce.

<apex:page controller="UploadDoc">
<apex:form >
  <apex:sectionHeader title="Upload a Document into Salesforce"/>
  <apex:pageblock >
      <apex:pageblocksection columns="1">
          <apex:inputfile value="{!myimage.body}" filename="{!myimage.Name}" />
          <apex:commandbutton value="Save" action="{!Savedoc}"/>


public class UploadDoc
Public Document mydoc;
    Public Document getmyimage()
        mydoc = new Document();
        return mydoc;
    Public Pagereference Savedoc()
        mydoc.folderid = UserInfo.getUserId(); 
        insert mydoc;
        return NULL;

Now I wonder how it is possible to upload a single file.
I do not want to give the option to search for the file I want the Apex class to run automatically (schedulable) to upload the specified file.
How do I do this?

Thank you,
Karan Khanna 6Karan Khanna 6
The approach you are taking requires manual efforts, someone has to open that VFPage and manually upload a file, I am afraid it can't be automated.
marys pindamarys pinda
Thank you!