0

We have an email service set up with the basic code as per the docs.

My Email Service looks like:

global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope envelope)
{
    Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

    ...
    do a bunch of stuff
    ...

    result.success = true;
    result.message = emailObj.Id;
    return result;
}

My understanding is if the result.successs == false, an email is sent to the sender with the result.message as the body.

What we're seeing is the sender is always receiving an email, even though it's impossible for the success to be false.

This is happening in both a sandbox and production.

Has anyone come across this before? Is there a known solution?

NOTE: I've ruled out a workflow/process builder as the cause of this email by adding some text to the result.message.

0

This is entirely re-producable and appears to be a defect with Salesforce.

To reproduce:

Create an Email Service with class:

global class myHandler implements Messaging.InboundEmailHandler {
      global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
          Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
          return result;
      }
  }

If you send an email to this Email Service, it will work fine.

As soon as you add in a result.message = 'some text';, it will always reply to the sender with that message.

The solution is to not set a result.message when you don't want an email sent to the sender.

Not cool Salesforce.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.