• joneill
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I have a requirement from a client to process an email via Email Services.  Unfortunately the attachment is a zip XML file.  Is there a way to unzip a file or read the file within the zip file using APEX code?

I wrote the code below hoping I can redirect once a Task is saved based on a checkbox.  If checked, user is redirected to the a new Opportunity in edit mode screen.  Not checked, just save the task.  I still have to put in the code to update the check to uncheck.  I can not get the page to redirect.  What am I missing?

 

Trigger:

 

trigger CreateNewOpty on Task (after insert) {

for(Task ta: Trigger.new){

if(ta.Create_Opportunity__c==true){

NewOptyRedirect obj = new NewOptyRedirect();
obj.Redirect(ta.Id);
}


}

 

Apex Code:

 

Public Class NewOptyRedirect {

public PageReference Redirect(string TaskId) {

String str='';
List<Task> taskList = [Select AccountId, Business_Segment__c, Description, Information_Discussed__c, Purpose_of_Call__c, Region__c, Test_Products__c From Task where id=: TaskId];
for(task t : taskList){
str='/006/e?retURL=%2F006%2Fo&accid='+replaceStr(t.AccountId) +'&opp3=CALL LOG OPPTY&opp5='+replaceStr(t.Purpose_of_Call__c)+'&00NG0000008u5yH='+replaceStr(t.Information_Discussed__c)+'&00NG0000008u5xd='+replaceStr(t.Test_Products__c )+'&0NG0000008vezX_lkold='+replaceStr(t.Information_Discussed__c)+'&00NG0000008vezX=Info Discussed: '+replaceStr(t.Information_Discussed__c)+' Comments: '+ replacestr(t.Description)+'&00NZ0000000cv0r='+ replacestr(t.Region__c)+replacestr(t.Business_Segment__c)+'&00NZ0000000cv0m='+replacestr(t.Business_Segment__c);
}

system.debug('here in the apex code-------------'+str);
//PageReference pageRef = new PageReference('http://www.google.com').view();
PageReference r= new PageReference('/apex/RedirectOpportunity');
r.setRedirect(true);
return r;

}

public String replaceStr(String s){
if(s==null) s='';
return s.replace('&', '%26');
}

}

I have a requirement from a client to process an email via Email Services.  Unfortunately the attachment is a zip XML file.  Is there a way to unzip a file or read the file within the zip file using APEX code?