0

This question has been asked at different times yet I am clueless to get the email address verified.

Here is my code to have the Task created.

All the answers to the previous questions says that there will be a hyperlink and if we click it will get verified but I am not seeing anything like that on my debug statement on in the Task record that got created.

Also I have made sure 'Email Deliverability is set to 'All'. I am also receiving the email, Task getting created but not sure how to narrow down to the verification link.enter image description here

global class emailHandler implements Messaging.InboundEmailHandler {
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
        // Create an InboundEmailResult object for returning the result of the
        // Apex Email Service
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();

        String myPlainText= '';

        // Add the email plain text into the local variable
        myPlainText = email.plainTextBody;

        // New Task object to be created
        Task[] newTask = new Task[0];

        // Try to look up any contacts based on the email from address
        // If there is more than one contact with the same email address,
        // an exception will be thrown and the catch statement will be called.
        try {
            Contact vCon = [SELECT Id, Name, Email
            FROM Contact
            WHERE Email = 'kf_email_service_handler@j6tb11xnkmmq4nl63cinmf90b9my8u13gqpne2pr8btqxxflh.3b-8p'
            LIMIT 1];

            // Add a new Task to the contact record we just found above.
            newTask.add(new Task(Description =  myPlainText,
                    Priority = 'Normal',
                    Status = 'Inbound Email',
                    Subject = email.subject,
                    IsReminderSet = true,
                    ReminderDateTime = System.now()+1,
                    WhoId =  vCon.Id));

            // Insert the new Task
            insert newTask;

            System.debug('New Task Object: ' + newTask );
            System.debug(email);
        }
        // If an exception occurs when the query accesses
        // the contact record, a QueryException is called.
        // The exception is written to the Apex debug log.
        catch (QueryException e) {
            System.debug('Query Issue: ' + e);
        }

        // Set the result to true. No need to send an email back to the user
        // with an error message
        result.success = true;

        // Return the result for the Apex Email Service
        return result;


    }
}

How can I verify my Org Wide email address?

Edit: I was able to resolve this. The task got created successfully as I have mentioned. The only other thing that I did was, went to Organization-Wide Email Addresses and under the email Address that I had created I clicked 'Resend'option. Now it updated the verification link on the Task.

  • Show your work in an answer so that if someone runs into a similar issue they know how to fix. – Dan Wooding Jan 25 '17 at 17:20
  • I am not able to enter the text as answer. Not sure why.. – user28452 Jan 26 '17 at 4:29

Your Answer

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

Browse other questions tagged or ask your own question.