Friday, September 21, 2012

Removing the last character from a String - Salesforce

Its easy to remove the last character from a string by using the Substring() method..
If X is a string  the last value can be removed by

                             String Y = X.Substring(0,X.length()-1);

Tuesday, September 18, 2012

EMAIL SERVICES IN SALESFORCE-EXAMPLE

I shared about the Salesforce's Email Services in my previous post..Creating Record by sending email to Salesforce - Part 1..

With this Email Service our part is to create an Apex Class to fetch the details from the email which we sent to Salesforce.

To fetch the data from incoming email we should make use of the Inbound Email messaging feature.

For Example:


global class recordfromEmail implements Messaging.InboundEmailHandler {

  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
    Messaging.InboundEnvelope envelope) {

    Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();

Oppotunity Oppty = New Oppotunity();

       String[] emailBody = email.plainTextBody.Split('\n',0); 
       
       oppty.Name = emailBody[0]; 
      
       oppty.Stage = emailBody[1]; 

       insert oppty;

  return Result;
 }

}

EMAIL SERVICES IN SALESFORCE


Yes , it is possible to create a record  just by sending an email to your Salesforce login.....

All can be done with the Salesforce's awesome feature called 'Email Services'.

With This Email Services in Salesforce all we have to do is,

  • Associate one Email id with Salesforce.
  • An Email from Salesforce will be generated and should be associated for.Sending mails to the salesforce.

Email Services can be created by

SetUp --- Develop --- Email Services



The generated email from Salesforce will be like

testemail@9q9zr6cc1w67kjgunhpqftj32.in.sandbox.salesforce.com


Email Service also facilitate users to get known to the errors occurring  while processing the email.

Users can specify an alternate email address to which the errors can be diverted..

Users need to write an Apex class to fetch the details in the email with the help of inBound email Class function.


That's it we can create a Email Service.......