• vanessa veron
  • NEWBIE
  • 360 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 6
    Likes Received
  • 0
    Likes Given
  • 83
    Questions
  • 224
    Replies
hello
I would like to send an email containing the error message if the wrong type a User request (example: select name from cont or selecttttttttttttttttttttttt).

I tried the above code but not get the email when the request is wrong.
Help me!

if I submit one request that returns empty value, it sends email
if I submit one request that returns values, it sends email
if I report a wrong request, it does not send email ... WHY????????????
string queryResultatString = '';
    list<sObject> queryResultat;
    System.QueryException q;
    try {
        queryResultat = (List<sObject>)database.query(requete);
        if (queryResultat.isEmpty()){
              String errMsg = 'EMPTY';
              Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
              String[] adressMail = new list<string> {mail};
              String subject = Label.StreamReport+' - '+Date.today().format();
              email.setSubject(subject);
              email.setToAddresses(adressMail);
              email.setPlainTextBody(Label.Hi+'\n\n'+errMsg );   
              Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }
        else
        if (!queryResultat.isEmpty()){
            for(sObject a: queryResultat)
            {
                queryResultatString = queryResultatString + string.valueof(a);
            }
       }
    }
    catch (System.QueryException e){
        if (e.getMessage() != null){
        String error = e.getMessage();
        Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
        String[] adressMail = new list<string> {mail};
        String subject = Label.StreamReport+' - '+Date.today().format();
        email.setSubject(subject);
        email.setToAddresses(adressMail);
        email.setPlainTextBody(Label.Hi+'\n\n'+error );   
        Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }
    }

hello
I would like to send an email containing the error message if the wrong type a User request (example: select name from cont or selecttttttttttttttttttttttt).

I tried the above code but not get the email when the request is wrong.
Help me!

string queryResultatString = '';
    list<sObject> queryResultat;
    System.QueryException q;
    try {
        queryResultat = (List<sObject>)database.query(requete);
        if (queryResultat.isEmpty()){
              String errMsg = 'EMPTY';
              Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
              String[] adressMail = new list<string> {mail};
              String subject = Label.StreamReport+' - '+Date.today().format();
              email.setSubject(subject);
              email.setToAddresses(adressMail);
              email.setPlainTextBody(Label.Hi+'\n\n'+errMsg );   
              Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }
        else
        if (!queryResultat.isEmpty()){
            for(sObject a: queryResultat)
            {
                queryResultatString = queryResultatString + string.valueof(a);
            }
       }
    }
    catch (System.QueryException e){
        if (e.getMessage() != null){
        String error = e.getMessage();
        Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
        String[] adressMail = new list<string> {mail};
        String subject = Label.StreamReport+' - '+Date.today().format();
        email.setSubject(subject);
        email.setToAddresses(adressMail);
        email.setPlainTextBody(Label.Hi+'\n\n'+error );   
        Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }
    }

Hi...
how can I test a request SOQL in Apex?

string queryResultatString = '';
   // requete: user inform into VisualPage
    list<sObject> queryResultat = (List<sObject>)database.query(requete);
    for(sObject a: queryResultat)
    {
        queryResultatString = queryResultatString + string.valueof(a);
        
    }
Thank you...
Hello

How do I create a test class to test sending email and create a document?
Unit test - method newPublier

global class AAAA implements System.Schedulable {
global String str{get;set;}
global String mail{get;set;}
global String nomJob{get;set;}
global String inputText{get;set;}
global String heure{get;set;}
global String minute{get;set;}
global String jourMois{get;set;}
global String mois{get;set;}
global String jourSemaine{get;set;}

global void execute(SchedulableContext sc) {
  newPublier();
}

global AAAA () {

}

global AAAA (String mail, String inputText, String heure, String minute, String jourMois, String mois, String jourSemaine) {
this.mail= mail;
this.inputText = inputText;
this.heure= heure;
this.minute= minute;
this.jourMois= jourMois;
this.mois= mois;
this.jourSemaine= jourSemaine;
}

public void setMail(String mail) {
    this.mail= mail;
}

public String getMail() {
    return mail;
}

public void setRequete(String inputText) {
    this.inputText= inputText;
}

public String getRequete() {
    return inputText;
}

public void setHeure(String heure) {
    this.heure= heure;
}

public String getHeure() {
    return heure;
}

public void setMinute(String minute) {
    this.minute= minute;
}

public String getMinute() {
    return minute;
}

public void setJourMois(String jourMois) {
    this.jourMois= jourMois;
}

public String getJourMois() {
    return jourMois;
}

public void setMois(String mois) {
    this.mois= mois;
}

public String getMois() {
    return mois;
}

public void setJourSemaine(String jourSemaine) {
    this.jourSemaine= jourSemaine;
}

public String getJourSemaine() {
    return jourSemaine;
}


public void schedulejob(){
        String aaa = getMail();
        String req = getRequete();
        String heu = getHeure();
        String min = getMinute();
        String jMois = getJourMois();
        String leMois = getMois();
        String jSemaine = getJourSemaine();
                
        String NomJobSchedulable = nomJob;
        AAAA p = new AAAA (aaa, req, heu, min, jMois, leMois,jSemaine);
        String sch = '0'+' '+min+' '+heu+' '+jMois+' '+leMois+' '+jSemaine;
 
        system.schedule(NomJobSchedulable , sch, p);   
}

public void newPublier(){

    String query=inputText;
    String premier=query.substringAfter('select ');   
    premier=  premier.substringBefore('from');
      
    string titre= premier+'\n';
    string contenuCSV = titre;

    string queryResultatString = '';

    list<sObject> queryResultat = (List<sObject>)database.query(inputText);
    for(sObject a: queryResultat)
    {

        queryResultatString = queryResultatString + string.valueof(a);
        
    }
    System.debug('Query result string:'+queryResultatString);

    list<string> queryLignes = queryResultatString.split('}');

    for(string s:queryLignes){
        list<string> queryColonnes = s.split(',');
        for(string st:queryColonnes){
            contenuCSV = contenuCSV + st.substringAfter('=') + ',';
        }

        contenuCSV = contenuCSV.substringBeforeLast(',').substringBeforeLast(',') + '\n';
    }

    String lignes = contenuCSV;
    List<String> parts = lignes.split('\n');
    integer lineNumber = queryResultat.size();

    integer nbLignesPJ = 1000;
    integer compterParties=0;

    for(integer i=0;i<lineNumber;i++){

      string fichierParties = parts[0] + '\n';

      if(math.mod(i,nbLignesPJ)<>0) continue;
      if((lineNumber-i)<nbLignesPJ){

        for(integer j=1;j<=(lineNumber-i);j++){
            fichierParties = fichierParties + parts[i+j] + '\n';
        }
      }
      if((lineNumber-i)>=nbLignesPJ){
         for(integer j=1;j<=nbLignesPJ;j++){
            fichierParties = fichierParties + parts[i+j] + '\n';
        }
      }
      //Envoyer le Mail
      Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
      blob csvBlob = Blob.valueOf(fichierParties);
      string csvNom = 'cases_fermes_'+Date.today().format()+'.csv';
      csvPJ.setFileName(csvNom);
      csvPJ.setBody(csvBlob);
      Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
      String[] adressMail = new list<string> {mail};
      compterParties++;
      String subject;
          subject = 'CSV - '+Date.today().format();
      email.setSubject(subject);
      email.setToAddresses(adressMail);
      email.setPlainTextBody('message');   
      email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
      Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
  }   
}

Hi...
global class AAAA implements System.Schedulable {
global String str{get;set;}
global String mail{get;set;}
global String nomJob{get;set;}
global String inputText{get;set;}
global String heure{get;set;}
global String minute{get;set;}
global String jourMois{get;set;}
global String mois{get;set;}
global String jourSemaine{get;set;}

global void execute(SchedulableContext sc) {
  newPublier();
}

global AAAA () {

}

global AAAA (String mail, String inputText, String heure, String minute, String jourMois, String mois, String jourSemaine) {
this.mail= mail;
this.inputText = inputText;
this.heure= heure;
this.minute= minute;
this.jourMois= jourMois;
this.mois= mois;
this.jourSemaine= jourSemaine;
}

public void setMail(String mail) {
    this.mail= mail;
}

public String getMail() {
    return mail;
}

public void setRequete(String inputText) {
    this.inputText= inputText;
}

public String getRequete() {
    return inputText;
}

public void setHeure(String heure) {
    this.heure= heure;
}

public String getHeure() {
    return heure;
}

public void setMinute(String minute) {
    this.minute= minute;
}

public String getMinute() {
    return minute;
}

public void setJourMois(String jourMois) {
    this.jourMois= jourMois;
}

public String getJourMois() {
    return jourMois;
}

public void setMois(String mois) {
    this.mois= mois;
}

public String getMois() {
    return mois;
}

public void setJourSemaine(String jourSemaine) {
    this.jourSemaine= jourSemaine;
}

public String getJourSemaine() {
    return jourSemaine;
}


public void schedulejob(){
        String aaa = getMail();
        String req = getRequete();
        String heu = getHeure();
        String min = getMinute();
        String jMois = getJourMois();
        String leMois = getMois();
        String jSemaine = getJourSemaine();
                
        String NomJobSchedulable = nomJob;
        AAAA p = new AAAA (aaa, req, heu, min, jMois, leMois,jSemaine);
        String sch = '0'+' '+min+' '+heu+' '+jMois+' '+leMois+' '+jSemaine;
 
        system.schedule(NomJobSchedulable , sch, p);   
}

public void newPublier(){

    String query=inputText;
    String premier=query.substringAfter('select ');   
    premier=  premier.substringBefore('from');
      
    string titre= premier+'\n';
    string contenuCSV = titre;

    string queryResultatString = '';

    list<sObject> queryResultat = (List<sObject>)database.query(inputText);
    for(sObject a: queryResultat)
    {

        queryResultatString = queryResultatString + string.valueof(a);
        
    }
    System.debug('Query result string:'+queryResultatString);

    list<string> queryLignes = queryResultatString.split('}');

    for(string s:queryLignes){
        list<string> queryColonnes = s.split(',');
        for(string st:queryColonnes){
            contenuCSV = contenuCSV + st.substringAfter('=') + ',';
        }

        contenuCSV = contenuCSV.substringBeforeLast(',').substringBeforeLast(',') + '\n';
    }

    String lignes = contenuCSV;
    List<String> parts = lignes.split('\n');
    integer lineNumber = queryResultat.size();

    integer nbLignesPJ = 1000;
    integer compterParties=0;

    for(integer i=0;i<lineNumber;i++){

      string fichierParties = parts[0] + '\n';

      if(math.mod(i,nbLignesPJ)<>0) continue;
      if((lineNumber-i)<nbLignesPJ){

        for(integer j=1;j<=(lineNumber-i);j++){
            fichierParties = fichierParties + parts[i+j] + '\n';
        }
      }
      if((lineNumber-i)>=nbLignesPJ){
         for(integer j=1;j<=nbLignesPJ;j++){
            fichierParties = fichierParties + parts[i+j] + '\n';
        }
      }
      //Envoyer le Mail
      Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
      blob csvBlob = Blob.valueOf(fichierParties);
      string csvNom = 'cases_fermes_'+Date.today().format()+'.csv';
      csvPJ.setFileName(csvNom);
      csvPJ.setBody(csvBlob);
      Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
      String[] adressMail = new list<string> {mail};
      compterParties++;
      String subject;
          subject = 'CSV - '+Date.today().format();
      email.setSubject(subject);
      email.setToAddresses(adressMail);
      email.setPlainTextBody('message');   
      email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
      Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
  }   
}



Someone give me the sample example of a test class to my class.
I want to publish my application but I do not know to do a test class.

Hi...

Someone give me the sample test class to my class:

global class AAAA implements System.Schedulable {
global String str{get;set;}
global String mail{get;set;}
global String nomJob{get;set;}
global String inputText{get;set;}
global String heure{get;set;}
global String minute{get;set;}
global String jourMois{get;set;}
global String mois{get;set;}
global String jourSemaine{get;set;}

global void execute(SchedulableContext sc) {
  newPublier();
}

global AAAA () {

}

global AAAA (String mail, String inputText, String heure, String minute, String jourMois, String mois, String jourSemaine) {
this.mail= mail;
this.inputText = inputText;
this.heure= heure;
this.minute= minute;
this.jourMois= jourMois;
this.mois= mois;
this.jourSemaine= jourSemaine;
}

public void setMail(String mail) {
    this.mail= mail;
}

public String getMail() {
    return mail;
}

public void setRequete(String inputText) {
    this.inputText= inputText;
}

public String getRequete() {
    return inputText;
}

public void setHeure(String heure) {
    this.heure= heure;
}

public String getHeure() {
    return heure;
}

public void setMinute(String minute) {
    this.minute= minute;
}

public String getMinute() {
    return minute;
}

public void setJourMois(String jourMois) {
    this.jourMois= jourMois;
}

public String getJourMois() {
    return jourMois;
}

public void setMois(String mois) {
    this.mois= mois;
}

public String getMois() {
    return mois;
}

public void setJourSemaine(String jourSemaine) {
    this.jourSemaine= jourSemaine;
}

public String getJourSemaine() {
    return jourSemaine;
}


public void schedulejob(){
        String aaa = getMail();
        String req = getRequete();
        String heu = getHeure();
        String min = getMinute();
        String jMois = getJourMois();
        String leMois = getMois();
        String jSemaine = getJourSemaine();
                
        String NomJobSchedulable = nomJob;
        AAAA p = new AAAA (aaa, req, heu, min, jMois, leMois,jSemaine);
        String sch = '0'+' '+min+' '+heu+' '+jMois+' '+leMois+' '+jSemaine;
 
        system.schedule(NomJobSchedulable , sch, p);   
}

public void newPublier(){

    String query=inputText;
    String premier=query.substringAfter('select ');   
    premier=  premier.substringBefore('from');
      
    string titre= premier+'\n';
    string contenuCSV = titre;

    string queryResultatString = '';

    list<sObject> queryResultat = (List<sObject>)database.query(inputText);
    for(sObject a: queryResultat)
    {

        queryResultatString = queryResultatString + string.valueof(a);
        
    }
    System.debug('Query result string:'+queryResultatString);

    list<string> queryLignes = queryResultatString.split('}');

    for(string s:queryLignes){
        list<string> queryColonnes = s.split(',');
        for(string st:queryColonnes){
            contenuCSV = contenuCSV + st.substringAfter('=') + ',';
        }

        contenuCSV = contenuCSV.substringBeforeLast(',').substringBeforeLast(',') + '\n';
    }

    String lignes = contenuCSV;
    List<String> parts = lignes.split('\n');
    integer lineNumber = queryResultat.size();

    integer nbLignesPJ = 1000;
    integer compterParties=0;

    for(integer i=0;i<lineNumber;i++){

      string fichierParties = parts[0] + '\n';

      if(math.mod(i,nbLignesPJ)<>0) continue;
      if((lineNumber-i)<nbLignesPJ){

        for(integer j=1;j<=(lineNumber-i);j++){
            fichierParties = fichierParties + parts[i+j] + '\n';
        }
      }
      if((lineNumber-i)>=nbLignesPJ){
         for(integer j=1;j<=nbLignesPJ;j++){
            fichierParties = fichierParties + parts[i+j] + '\n';
        }
      }
      //Envoyer le Mail
      Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
      blob csvBlob = Blob.valueOf(fichierParties);
      string csvNom = 'cases_fermes_'+Date.today().format()+'.csv';
      csvPJ.setFileName(csvNom);
      csvPJ.setBody(csvBlob);
      Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
      String[] adressMail = new list<string> {mail};
      compterParties++;
      String subject;
          subject = 'CSV - '+Date.today().format();
      email.setSubject(subject);
      email.setToAddresses(adressMail);
      email.setPlainTextBody('message');   
      email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
      Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
  }   
}

I want to publish my application but I do not know to do a test class.
I have a problem to upload  a package:

Upload Failed
No test methods found in the Apex code included in the package. At least 75% test coverage is required.


Help me please
How is it possible to test an Apex Application in mode application before publishing it on the AppExchange?
I want to make the application available to some users to test, how do I do that?

Thank you

Hi...

how do I delete a document from SF in Apex code?
I created the document in Method 1 and I want to delete it in method 2.
Document mydoc = new Document();
     mydoc.Name =nomFic;
     mydoc.Type = 'csv';
     mydoc.folderid = UserInfo.getUserId(); 
     mydoc.Body = csvBlob;
     insert mydoc;
     delete DOC_CREATED_PREVIOUS;

I have a Visualforce page that informs the User request and the file name.

I have a classe apex Schedulable, how do I use the name entered in the Visualforce page file to create the document through a schedulable job.
I think it's a future action is not'm getting retrieve the name to create the file appears always NULL.

Hi

how do I submit my Visualforce page with buttons language:
English, Portuguese and Spanish?

Its a quick way to do this, using features of Salesforce?
HIII...
it is possible to retrieve the updated value in the table contrigger?
How I do it?

I just want to update the value into my custom object and not update the table CronTrigger (this is not possible).
Give me an example please
Is it possible:

Set createddate in name job scheduler apex:

system.schedule(NomJobSchedulable+'_'+CronTrigger.CreatedDate, expression, p);


Hi...
I have a custom object that I would like to change the value of field PREVIOUS_FIRE this my object, when the PreviousFireTime of CronTrigger value be changed.
How do I update the field from my custom object based on field CronTrigger?

Thank you
Hi...
I have a custom object that I would like to change the value of field PREVIOUS_FIRE this my object, when the PreviousFireTime of CronTrigger value be changed.
How do I update the field from my custom object based on field CronTrigger?

Thank you
I can create a trigger to update the field value from my custom object after an update of the PreviousFireTime field into CronTrigger?
How can I do this?

Thank you
Hello, I am trying to get the value of the last run of each JOB and introduce a table.
I have to use another variable and not PreviousFireTime of CronTrigger because I will treat this data with other values ​​before you present it.

Somebody help me, the code displays the date of the last JOB only.

APEX:
.........
variableA = [SELECT  CronJobDetail.Name, CreatedDate, State, PreviousFireTime, NextFireTime,CronExpression FROM CronTrigger where OwnerId = '00524'];
public String infoLastExec{get;set;} 
Datetime getPlan;
 
    for(CronTrigger a: variableA){
                getPlan = a.PreviousFireTime;
                infoLastExec = getPlan.format();
            }

.............
Visualforce:
<apex:column headervalue="Last Executi" value="{!infoLastExec}"/>

Result:
01/07/2014 17:00
01/07/2014 17:00
01/07/2014 17:00

Thank you!!!
Hello,

I'm trying to do the upgrade of the PreviousFireTime field into CronTrigger, but I try an error:

Error: Compile Error: Field is not writeable: CronTrigger.CronExpression
LINE: ct.PreviousFireTime = VariablePreviousExec;

Why?

....

 CronTrigger[] acctsList = [SELECT PreviousFireTime FROM CronTrigger where CronJobDetail.Name =: VariableName ];
        for (CronTrigger ct : acctsList) {
            ct.PreviousFireTime = VariablePreviousExec;
        }
        
        try {
            upsert acctsList;
        } catch (DmlException e) {
            // code...
        }

.....

Thank you!!!
I have a function JS to check if a checkbox is checked, but does not work. Why?

<apex:page standardController="CronTrigger" >

<style type="text/css">
        .classeHoraire { width: 60px; }
        .classeBig { width: 600px; }
        .imageCenter {display: block; margin-left: auto; margin-right: auto;}
</style>
    
<script type="text/javascript">

function verify(){
var checkNomJob = '{!verifiyNomJob}';

if (document.getElementById("{!$Component.theform.block01.pageSess01.outputPane01.ckLun}").checked){
    alert("Messageee");
}
}
</script>

  <apex:form id="theform" > 
  <apex:PageBlock id="block01">

    Job Name.:&nbsp;<apex:inputText id="nomJobIP" value="{!nomJob}" />  
    <br /><br />
        
 <br/><br/>
 <apex:pageBlockSection columns="2" id="pageSess01">
    <apex:outputPanel id="outputPane01">
    
    <apex:inputCheckbox id="ckLun" value="{!checkLundi}" disabled="{!disableSemaineCheckModification}" />Lundi<br />
    <apex:inputCheckbox id="ckMar" value="{!checkMardi}" disabled="{!disableSemaineCheckModification}" />Mardi<br />
    </apex:outputPanel>
</apex:pageBlockSection>

.....

</apex:page>

Hi...
I have a Developer Edition. I am using it for over a month and it is not over yet. How come?
Is there a way to use SF FREE?

What is the best version and the price to develop applications, making maintenance and publish them on the AppExchange?

Thank you,
Hi...
I have a Developer Edition. I am using it for over a month and it is not over yet. How come?
Is there a way to use SF FREE?

What is the best version and the price to develop applications, making maintenance and publish them on the AppExchange?

Thank you,
Hello,

I have 4 selectList and I would like when I click on one, the other three remain disable...
I click on another (even disable), the others are disable and it is enable...

How do I do this with JS??

I did something like this, but DONT WORK:

function enableJusteWeek(){
document.getElementById("{!$Component.theform.block01.month}").disabled;
document.getElementById("{!$Component.theform.block01.year}").disabled;
document.getElementById("{!$Component.theform.block01.week}").disabled;
}

.....

<apex:selectList size="7" value="{!days}" multiselect="true" onclick="enableJusteWeek();">

Hello!

It's possible to pass a valueof the method in page 1 to INPUT TEXT page 2.

I dont have sucess!!!!

Help me please!!!!
Hi
Is it possible to modify a job schedulable created?
How do I do this in SF if I don't have the SAVE button on the part of MANAGE schedulable job?

Thank you
Hello!
When I use a FREE version of Salesforce this version contains the same features as the paid version?
The FREE version of test for 30 days is equal to the paid version of Salesforce?

Thank you,
How do I make my code be Schedulable with the informations that the User inform into Visualforce PAGE?

THE CODE and THE PAGE:

global class CSVTest implements System.Schedulable {
    public String mailSouhaite {get; set;}
    public string inputText {get; set;}
   
    global void execute(SchedulableContext sc) {
        planifier();
    }
 
public void planifier(){
    String query=inputText;
    String premier=query.substringAfter('select ');
    premier=  premier.substringBefore('from');
   
    string titre= premier+'\n';
    string contenuCSV = titre;

    string queryResultatString = '';
    list<sObject> queryResultat = (List<sObject>)database.query(inputText);
    for(sObject a: queryResultat)
    {

        queryResultatString = queryResultatString + string.valueof(a);
    }

    list<string> queryLignes = queryResultatString.split('}');

    for(string s:queryLignes){
        list<string> queryColonnes = s.split(',');
        for(string st:queryColonnes){
            contenuCSV = contenuCSV + st.substringAfter('=') + ',';
        }
        contenuCSV = contenuCSV.substringBeforeLast(',').substringBeforeLast(',') + '\n';
    }
    String lignes = contenuCSV;
    List<String> parts = lignes.split('\n');
    integer lineNumber = queryResultat.size();
    integer nbLignesPJ = 50;
    integer compterParties=0;

    for(integer i=0;i<lineNumber;i++){

      string fichierParties = parts[0] + '\n';

      if(math.mod(i,nbLignesPJ)<>0) continue;
      if((lineNumber-i)<nbLignesPJ){
     
        for(integer j=1;j<=(lineNumber-i);j++){
            fichierParties = fichierParties + parts[i+j] + '\n';
        }
      }
      if((lineNumber-i)>=nbLignesPJ){
         for(integer j=1;j<=nbLignesPJ;j++){
            fichierParties = fichierParties + parts[i+j] + '\n';
        }
      }
      //Send Mail
      Messaging.EmailFileAttachment csvPJ = new Messaging.EmailFileAttachment();
      blob csvBlob = Blob.valueOf(fichierParties);
      string csvNom = 'cases_fermes_'+Date.today().format()+'.csv';
      csvPJ.setFileName(csvNom);
      csvPJ.setBody(csvBlob);
      Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
      String[] adressMail = new list<string> {mailSouhaite};
      compterParties++;
      String subject;
      if (compterParties >=2)
          subject = 'CSV - '+Date.today().format()+' - Partie '+compterParties;
      else
          subject = 'CSV - '+Date.today().format();
      email.setSubject(subject);
      email.setToAddresses(adressMail);
      email.setPlainTextBody('Mail....');
      email.setFileAttachments(new Messaging.EmailFileAttachment[]{csvPJ});
      Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
    }
}
}

-------------------------------------------------------------------------------------------------------------------------

PAGE

<apex:page controller="CSVTest">
  <apex:form >
  <apex:PageBlock >
    :::::::::: TEST TEST TEST :::::::::: <br /><br />
    Mail..........:&nbsp;<apex:inputText styleClass="classeMail" value="{!mailSouhaite}"/><br /><br />
    Request  :&nbsp;&nbsp;<apex:inputText styleClass="classeRequete" value="{!inputText}"/><br /><br />
    <apex:inputCheckbox id="Monday "/>      
    <apex:outputLabel value="Monday " for="Monday "/><br/>
    <apex:inputCheckbox id="Tuesday "/>      
    <apex:outputLabel value="Tuesday " for="Tuesday "/><br/>
    <apex:inputCheckbox id="Wednesday "/>      
    <apex:outputLabel value="Wednesday " for="Wednesday "/><br/>
    <apex:inputCheckbox id="Thursday "/>      
    <apex:outputLabel value="Thursday " for="Thursday "/><br/>
    <apex:inputCheckbox id="Friday "/>      
    <apex:outputLabel value="Friday " for="Friday "/><br/>
    <apex:inputCheckbox id="Saturday "/>      
    <apex:outputLabel value="Saturday " for="Saturday "/><br/>
    <apex:inputCheckbox id="Sunday"/>      
    <apex:outputLabel value="Sunday" for="Sunday"/><br/><br/>
	
    When:
    <apex:selectList size="1">
         <apex:selectOption itemValue="00:00" itemLabel="00:00"/>
         <apex:selectOption itemValue="01:00" itemLabel="01:00"/>
         <apex:selectOption itemValue="02:00" itemLabel="02:00"/>
         <apex:selectOption itemValue="03:00" itemLabel="03:00"/>
         <apex:selectOption itemValue="04:00" itemLabel="04:00"/>
         <apex:selectOption itemValue="05:00" itemLabel="05:00"/>
         <apex:selectOption itemValue="06:00" itemLabel="06:00"/>
         <apex:selectOption itemValue="07:00" itemLabel="07:00"/>
         <apex:selectOption itemValue="08:00" itemLabel="08:00"/>
         <apex:selectOption itemValue="09:00" itemLabel="09:00"/>
         <apex:selectOption itemValue="10:00" itemLabel="10:00"/>
         <apex:selectOption itemValue="11:00" itemLabel="11:00"/>
         <apex:selectOption itemValue="12:00" itemLabel="12:00"/>
      </apex:selectList>
      <br/><br/>
    
    
    <apex:commandButton value="SEND" action="{!planifier}"/> <br/><br/>
   
  </apex:PageBlock>
  </apex:form>
</apex:page>


Help me please, THANK YOU!


hello
I would like to send an email containing the error message if the wrong type a User request (example: select name from cont or selecttttttttttttttttttttttt).

I tried the above code but not get the email when the request is wrong.
Help me!

if I submit one request that returns empty value, it sends email
if I submit one request that returns values, it sends email
if I report a wrong request, it does not send email ... WHY????????????
string queryResultatString = '';
    list<sObject> queryResultat;
    System.QueryException q;
    try {
        queryResultat = (List<sObject>)database.query(requete);
        if (queryResultat.isEmpty()){
              String errMsg = 'EMPTY';
              Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
              String[] adressMail = new list<string> {mail};
              String subject = Label.StreamReport+' - '+Date.today().format();
              email.setSubject(subject);
              email.setToAddresses(adressMail);
              email.setPlainTextBody(Label.Hi+'\n\n'+errMsg );   
              Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }
        else
        if (!queryResultat.isEmpty()){
            for(sObject a: queryResultat)
            {
                queryResultatString = queryResultatString + string.valueof(a);
            }
       }
    }
    catch (System.QueryException e){
        if (e.getMessage() != null){
        String error = e.getMessage();
        Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
        String[] adressMail = new list<string> {mail};
        String subject = Label.StreamReport+' - '+Date.today().format();
        email.setSubject(subject);
        email.setToAddresses(adressMail);
        email.setPlainTextBody(Label.Hi+'\n\n'+error );   
        Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }
    }

hello
I would like to send an email containing the error message if the wrong type a User request (example: select name from cont or selecttttttttttttttttttttttt).

I tried the above code but not get the email when the request is wrong.
Help me!

string queryResultatString = '';
    list<sObject> queryResultat;
    System.QueryException q;
    try {
        queryResultat = (List<sObject>)database.query(requete);
        if (queryResultat.isEmpty()){
              String errMsg = 'EMPTY';
              Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
              String[] adressMail = new list<string> {mail};
              String subject = Label.StreamReport+' - '+Date.today().format();
              email.setSubject(subject);
              email.setToAddresses(adressMail);
              email.setPlainTextBody(Label.Hi+'\n\n'+errMsg );   
              Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }
        else
        if (!queryResultat.isEmpty()){
            for(sObject a: queryResultat)
            {
                queryResultatString = queryResultatString + string.valueof(a);
            }
       }
    }
    catch (System.QueryException e){
        if (e.getMessage() != null){
        String error = e.getMessage();
        Messaging.SingleEmailMessage email =new Messaging.SingleEmailMessage();
        String[] adressMail = new list<string> {mail};
        String subject = Label.StreamReport+' - '+Date.today().format();
        email.setSubject(subject);
        email.setToAddresses(adressMail);
        email.setPlainTextBody(Label.Hi+'\n\n'+error );   
        Messaging.SendEmailResult [] envoyer = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        }
    }

Hi...
how can I test a request SOQL in Apex?

string queryResultatString = '';
   // requete: user inform into VisualPage
    list<sObject> queryResultat = (List<sObject>)database.query(requete);
    for(sObject a: queryResultat)
    {
        queryResultatString = queryResultatString + string.valueof(a);
        
    }
Thank you...
Hello

I have a method to pass the values into page 2
But the inputHidden dont work. Why???

APEX:
public PageReference modifier(){

PageReference pageRef= new PageReference('/apex/BBBBPage2');
pageRef.getParameters().put('par' ,jobInfoMail);

pageRef.setRedirect(true);
return pageRef;
}

VISUALFORCE:

.........

function prepopulate(){

var getOPTNomJob = document.getElementById("{!$Component.theform.block01.nomJobOP}").innerHTML;
document.getElementById("{!$Component.theform.block01.nomJobIP}").value= getOPTNomJob ;

}

..........  
 

<apex:inputHidden value="{!$CurrentPage.parameters.par}" id="nomJobOP"/><br />
    Nom Job.:&nbsp;<apex:inputText id="nomJobIP" value="{!nomJob}" onclick="prepopulate();return false;"/><br /><br />
Thank you