0

Error message:

<html>
<body>

<table cellspacing=10>
    <tr>
        <td><span style="font-weight: bold; font-size: 12pt;">Illegal Request</span></td>
    </tr>
    <tr>
        <td>You have sent us an Illegal URL or an improperly formatted request. 
        </td>
    </tr>
    <tr>
        <td>
            
        </td>
    </tr>
</table>



<!-- Body events -->
<script type="text/javascript">function bodyOnLoad(){if(window.PreferenceBits){window.PreferenceBits.prototype.csrfToken="null";};}function bodyOnBeforeUnload(){}function bodyOnFocus(){}function bodyOnUnload(){}</script>
            
</body>
</html>


<!--
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
-->

The method in question:

 /**
 * send email to admins/devs of deactivation error
 * @param errorMessage
 */

public static void sendErrorEmail(string errorMessage){
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    String[] toAddresses = new String[] {'[email protected]'};
    Messaging.reserveSingleEmailCapacity(1);
    (toAddresses);
    mail.setReplyTo('[email protected]');  
    mail.setSenderDisplayName('Apex error message');
    mail.setSubject('User could not be deactivated');
    mail.setPlainTextBody('Could not deactivate user' + errorMessage);
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
} 

So i'm not entirely sure what i'm missing?

2

1 Answer 1

2

It doesn't look like you're specifying a recipient: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm#apex_Messaging_SingleEmailMessage_setToAddresses

All emails must have a recipient value in at least one of the following fields:
- toAddresses
- ccAddresses
- bccAddresses
- targetObjectId

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .