function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abdul RazzaqAbdul Razzaq 

Inline Email handler

Unable to retrieve information from the email sent to salesforce.

I am probably trying to check information through debug logs.. 

help ASAP!!

global class processApplicant implements 
        Messaging.InboundEmailHandler {
       
 global Messaging.InboundEmailResult handleInboundEmail(
  Messaging.InboundEmail email, 
  Messaging.InboundEnvelope envelope) {
Messaging.InboundEmailResult result = 
        new Messaging.InboundEmailresult();
        
        system.debug('---------------------------------------------------------------result1------'+result);
        // Captures the sender's email address
String emailAddress = envelope.fromAddress;
        system.debug('-----------------------------------------------------------------emailaddress----'+emailaddress); 
  // Retrieves the sender's first and last names
String fName = email.fromname.substring(
        0,email.fromname.indexOf(' '));
String lName = email.subject;
         system.debug('--------------------------------------------------------------fname-------'+fname);
                 system.debug('--------------------------------------------------------lname-------------'+lname);
  // Retrieves content from the email. 
  // Splits each line by the terminating newline character
  // and looks for the position of the phone number and city
String[] emailBody = email.plainTextBody.split('\n', 0);
String phoneNumber = emailBody[0].substring(6);
String city = emailBody[1].substring(5);
        
        system.debug('---------------------------------------------------------------------'+result);
return result;
    }   
}

Pankaj_GanwaniPankaj_Ganwani
Hi,

Can you please make sure your email service is properly configured? Check for the 'EmailToApexhandler' operation in debug logs.
Abdul RazzaqAbdul Razzaq
I am getting an xml response in i2.getweather(city, country). and I want that to be retrieved in normal way... help....



global class emailhandler2 implements Messaging.InboundEmailHandler {
  global Messaging.InboundEmailResult handleInboundEmail(
  Messaging.InboundEmail email,
  Messaging.InboundEnvelope envelope)
  {
  
  WeatherCheckIn__c[] newWeathercheckIn = new WeatherCheckIn__c[0];
  
    String subject = email.subject;
   
   String[] emailsub = email.subject.split('#', 0);
   String country = emailsub[0];
   String city = emailsub[1];
   
     WeatherService callingWeather = new WeatherService();
     WeatherService.GlobalWeatherSoap i2 = new WeatherService.GlobalWeatherSoap();
 *****************************  
 string l=i2.GetWeather(city,country);
    ***********************************
system.debug('---------------------------------------------------------'+l);
   
   try
        {
      newWeathercheckIn.add(new WeatherCheckIn__c(City__c = city,
      Country__c = country));
 
      insert newWeathercheckIn;
   }
        
   catch (System.DmlException e)
   {
System.debug('ERROR: Not able to create newweathercheckin: ' + e);
   }
   
     system.debug('----------------------------------------subject--------------------'+subject);
       system.debug('--------------------------------------------------country--'+country);
       system.debug('--------------------------------------------city---------'+city);
   // Account account = [SELECT Name FROM Account WHERE Id = :matcher.group(0)];
   // account.Name = email.plainTextBody;
    //update account;

    Messaging.InboundEmailresult result = new Messaging.InboundEmailResult();
    result.message = 'Your mail has been recieved';
  
    return result;
  }
}
Abdul RazzaqAbdul Razzaq
I tried this but method is not being called ask me for parameters 


public pagereference Parsexmlfile(){
       DOM.Document xmlDOC = new DOM.Document(); 
 >>>>>>>>>>>>>>>>>>>>>>>> I tried this but method is not being called ask me for parameters >>>>>>>>>>>>>>>>>  
   xmlstring= i2.GetWeather(hyderabad, india);
       system.debug('****xmlstring'+xmlstring);
      // xmlstring=xmlstring.Substring(1,xmlstring.length());
       //outxmlstring=xmlstring;
       xmlDOC.load(xmlstring); 
       DOM.XMLNode rootElement = xmlDOC.getRootElement();
       outxmlstring=String.valueof(xmlDOC.getRootElement().getName());//gives you root element Name
       for(DOM.XMLNode xmlnodeobj:xmlDOC.getRootElement().getChildElements()){ //gives you all childnodes list
          if(xmlnodeobj.getName()=='Name')
            outxmlstring+='\nAccount Name:'+xmlnodeobj.getText();// it gives you text node
          if(xmlnodeobj.getName()=='Type')
            outxmlstring+='\nAccount Type:'+xmlnodeobj.getText();  
          if(xmlnodeobj.getName()=='Industry')
            outxmlstring+='\nAccount Industry:'+xmlnodeobj.getText();
       }
       
      return null;
    }
}