• Huang Zhigang
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 2
    Replies
Hi Everyone,
Now I created a email service and SFDC auto generated a email account for me, something like xxxxx@xxxx.xxxx.xxx.sfdc.com, I am now very curious why SFDC provide email service for us? ask us to copy and paste that complicated email as "To" and send? I don't believe there are someone who want to use this way to send email, so what's the scenario when we use the email service?

too many concerns about the email service, back to my key question,I want to have a way that I can configure or write code to use the email service account(xxxx@xxxx.xxxx.xx.sfdc.com) as the sender, I try to use org-wide addresses and add this email account into it, but it need to verify the account, SFDC send the verified code to this email, but there is no way to get the verified code. So seems I can't find where I can configure it or what code I can implement this requirement, could someone give me help one this, thanks in adavnce.





es@u-2agtjrx7aayu881gelxozyffbed482yszj8u5h6drswcntsye.28-jc4jeac.ap2.apex.salesforce.com
Hi Everyone,
Now I created a email service and SFDC auto generated a email account for me, something like xxxxx@xxxx.xxxx.xxx.sfdc.com, I am now very curious why SFDC provide email service for us? ask us to copy and paste that complicated email as "To" and send? I don't believe there are someone who want to use this way to send email, so what's the scenario when we use the email service?

too many concerns about the email service, back to my key question,I want to have a way that I can configure or write code to use the email service account(xxxx@xxxx.xxxx.xx.sfdc.com) as the sender, I try to use org-wide addresses and add this email account into it, but it need to verify the account, SFDC send the verified code to this email, but there is no way to get the verified code. So seems I can't find where I can configure it or what code I can implement this requirement, could someone give me help one this, thanks in adavnce.





es@u-2agtjrx7aayu881gelxozyffbed482yszj8u5h6drswcntsye.28-jc4jeac.ap2.apex.salesforce.com

Neat little trick in case you need it:

 

1. Create the class for the Inbound Email Handler:

 

 

global class myHandler implements Messaging.InboundEmailHandler {
      global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
          Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
          
          
          if(email.htmlBody.contains('We have received the following request to add this'))
              sendVerificationEmail(email, 'YOUR EMAIL ADDRESS HERE');
          
          
          return result;
      }

    
    private void sendVerificationEmail(Messaging.InboundEmail email, String toAddress){
    
    
        Messaging.reserveSingleEmailCapacity(1);
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {toAddress};

        
        mail.setToAddresses(toAddresses);
        mail.setSenderDisplayName('WHATEVER YOU WANT HERE');

        mail.setSubject('WHATEVER YOU WANT HERE');
        mail.setPlainTextBody(email.plainTextBody);
        mail.setHtmlBody(email.htmlBody);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

    
    
    }

  }

 

2. Create the email service

3. Copy the email service address

4. Create a new Org Default Email Addres using the address from the email service

5. It will send the confirmation email to the email handler which will forward it on to the email address you specified so you can click the link to verify

6. Now you can use the address in workflows.

 

Why would you want to do this:

 

** So you can send email notifications to addresses using workflow so you do not have issues with gov limits. The email can be replied to and then you can proccess the reply (Like in a custom approval process).

 

 

 

Neat little trick in case you need it:

 

1. Create the class for the Inbound Email Handler:

 

 

global class myHandler implements Messaging.InboundEmailHandler {
      global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
          Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
          
          
          if(email.htmlBody.contains('We have received the following request to add this'))
              sendVerificationEmail(email, 'YOUR EMAIL ADDRESS HERE');
          
          
          return result;
      }

    
    private void sendVerificationEmail(Messaging.InboundEmail email, String toAddress){
    
    
        Messaging.reserveSingleEmailCapacity(1);
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {toAddress};

        
        mail.setToAddresses(toAddresses);
        mail.setSenderDisplayName('WHATEVER YOU WANT HERE');

        mail.setSubject('WHATEVER YOU WANT HERE');
        mail.setPlainTextBody(email.plainTextBody);
        mail.setHtmlBody(email.htmlBody);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

    
    
    }

  }

 

2. Create the email service

3. Copy the email service address

4. Create a new Org Default Email Addres using the address from the email service

5. It will send the confirmation email to the email handler which will forward it on to the email address you specified so you can click the link to verify

6. Now you can use the address in workflows.

 

Why would you want to do this:

 

** So you can send email notifications to addresses using workflow so you do not have issues with gov limits. The email can be replied to and then you can proccess the reply (Like in a custom approval process).