• Eva Tannenbaum
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies

Hi all,
I have a scenario where when I autoforwarded a html content email to an email service and it appears blank(the apex class for the email service shows null when using htmlbody). However, when forward the same email maullaly, the email is processed successfully. How can I fix the problem that the email appears null when automatically forwarded?

Hi,

I want to automate a process that when a xls. file is emailed into email service, the inventory info is updated. The problem is that inbound email handle xls file as binary attachment, which turns the file content type to "application/octet-stream". Is there any way to convert application/octet-stream to UTF8 with apex?

Hello~

I want to update records after an email with csv attachment is recived. The attachement is passed in the function in UpdateAvailableCGUnite class through a trigger. The for loop does not iterate, and I don't know why. Also, 

public class UpdateAvailableCGUnit {

    /*
      public PageReference UpdateCG() {
        PageReference pageRef = new PageReference('/apex/UpdateAvailableCGUnit');
        return null;
    }


    public Blob csvFileBody{get;set;}
    public string csvAsString{get;set;}
    public String[] csvFileLines{get;set;}
    //public String[] notification{get;set;}
    public List<ECS__Supplier_Product__c> updatelist{get;set;}
   
    
    public UpdateAvailableCGUnit(){
        csvFileLines = new String[]{};
        updatelist = New List<ECS__Supplier_Product__c>();
    }
 */   
     
  public static void importCSVFile(Attachment a){
       
      	List<ECS__Supplier_Product__c> updatelist ;
      	List<ECS__Supplier_Product__c> unupdatelist ;
      
     if(a != null){ 	
      	Blob csvFileBody = a.body;
        string csvAsString = csvFileBody.toString();
        

        String[] csvFileLines = csvAsString.split('\n');
      	String[] SKU = new string[]{''};
     	integer count = csvFileLines.size();
      
      
      //Query existing CG SKU, Qty, and price to existingCG list
		List<ECS__Supplier_Product__c> existingCG = [SELECT Name, ECS__Available_Units__c, ECS__Supplier_SKU__c  FROM ECS__Supplier_Product__c];
        ECS__Supplier_Product__c supp = new ECS__Supplier_Product__c(); 
         
         
      //map csv col. and add to updatelist 
        system.debug(count);
      	
      	for(Integer i=1; i<count; i++){
			system.debug(count);
            string[] csvRecordData = csvFileLines[i].split(',');
            supp.ECS__Supplier_SKU__c = csvRecordData[0];
      		supp.ECS__Available_Units__c = Integer.valueOf(csvRecordData[1].trim());
            
            if(existingCG[i].ECS__Supplier_SKU__c == csvRecordData[0]){
                updatelist.add(supp);
            }
            else{
                unupdatelist.add(supp);
            }
             system.debug(unupdatelist);
      		 system.debug(updatelist);
   			
          }
     
      }
    	
      try{
      	update updatelist;
      }
      catch(Exception e){
      	system.debug(e);
      }
	}
}

[45]|i|1
Then the loop is not looping and seems to go back to trigger and recalled the function again.

09:47:11:242 FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object
User-added image

 

Hi,

I've written a custom email handler to deal with some automated emails we receive. I first worked on this in a Sandbox, and everything was working fine. After pushing this to our next environment, though, it's not functioning at all. I'm not getting any errors, just nothing is happening. What should happen is that an incoming email will create a case, unless there is already a case with that subject, in which case it will insert a comment. When I send an email to my email service address, though, nothing happens.

I have already checked that deliverability is set to all emails. I've made sure the email service is set to active. I made sure all the code came over. I'm not sure what else I should check or what else it could be. Any ideas?

Thanks!

Hello~

I want to update records after an email with csv attachment is recived. The attachement is passed in the function in UpdateAvailableCGUnite class through a trigger. The for loop does not iterate, and I don't know why. Also, 

public class UpdateAvailableCGUnit {

    /*
      public PageReference UpdateCG() {
        PageReference pageRef = new PageReference('/apex/UpdateAvailableCGUnit');
        return null;
    }


    public Blob csvFileBody{get;set;}
    public string csvAsString{get;set;}
    public String[] csvFileLines{get;set;}
    //public String[] notification{get;set;}
    public List<ECS__Supplier_Product__c> updatelist{get;set;}
   
    
    public UpdateAvailableCGUnit(){
        csvFileLines = new String[]{};
        updatelist = New List<ECS__Supplier_Product__c>();
    }
 */   
     
  public static void importCSVFile(Attachment a){
       
      	List<ECS__Supplier_Product__c> updatelist ;
      	List<ECS__Supplier_Product__c> unupdatelist ;
      
     if(a != null){ 	
      	Blob csvFileBody = a.body;
        string csvAsString = csvFileBody.toString();
        

        String[] csvFileLines = csvAsString.split('\n');
      	String[] SKU = new string[]{''};
     	integer count = csvFileLines.size();
      
      
      //Query existing CG SKU, Qty, and price to existingCG list
		List<ECS__Supplier_Product__c> existingCG = [SELECT Name, ECS__Available_Units__c, ECS__Supplier_SKU__c  FROM ECS__Supplier_Product__c];
        ECS__Supplier_Product__c supp = new ECS__Supplier_Product__c(); 
         
         
      //map csv col. and add to updatelist 
        system.debug(count);
      	
      	for(Integer i=1; i<count; i++){
			system.debug(count);
            string[] csvRecordData = csvFileLines[i].split(',');
            supp.ECS__Supplier_SKU__c = csvRecordData[0];
      		supp.ECS__Available_Units__c = Integer.valueOf(csvRecordData[1].trim());
            
            if(existingCG[i].ECS__Supplier_SKU__c == csvRecordData[0]){
                updatelist.add(supp);
            }
            else{
                unupdatelist.add(supp);
            }
             system.debug(unupdatelist);
      		 system.debug(updatelist);
   			
          }
     
      }
    	
      try{
      	update updatelist;
      }
      catch(Exception e){
      	system.debug(e);
      }
	}
}

[45]|i|1
Then the loop is not looping and seems to go back to trigger and recalled the function again.

09:47:11:242 FATAL_ERROR System.NullPointerException: Attempt to de-reference a null object
User-added image