0

I have an image in String in a different method. I am trying this String to include in the HTML body of the other method, i.e SingleEmailMessage().

I have checked the Deliverability and its all mail.

Am unable to receive the emails at all. What's that am missing? Pls help.

Code:

Public void SingleEmailMessage()
{
    // First, reserve email capacity for the current Apex transaction to ensure
// that we won't exceed our daily email limits when sending email after
// the current transaction is committed.
Messaging.reserveSingleEmailCapacity(5);

// Processes and actions involved in the Apex transaction occur next,
// which conclude with sending a single email.

// Now create a new single email message object
// that will send out a single email to the addresses in the To, CC & BCC list.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

// Strings to hold the email addresses to which you are sending the email.
String[] toAddresses = new String[] {'[email protected]'}; 
String[] ccAddresses = new String[] {'[email protected]'};


// Assign the addresses for the To and CC lists to the mail object.
mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);

// Specify the address used when the recipients reply to the email. 
mail.setReplyTo('[email protected]');

// Specify the name used as the display name.
mail.setSenderDisplayName('Support');

// Specify the subject line for your email address.
mail.setSubject('New Evaluation Created : ' + valuation__c.name);

// Set to True if you want to BCC yourself on the email.
mail.setBccSender(false);

// Optionally append the salesforce.com email signature to the email.
// The email address of the user executing the Apex Code will be used.
mail.setUseSignature(false);

// Specify the text content of the email.
// mail.setPlainTextBody('Your Case: ' + case.Id +' has been created.');


//mail.setHtmlBody('Hello, Below is the image: <br> <br> <img src="http://goo.gl/LxzrvC"/>');
mail.setHtmlBody('Hello, Below is the image: <br> <br>' + img);

    System.debug(img);

// Send the email you have created.
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

   }
// Mail methods ends

public void getdetails()
{
if ( caseId != null)
{

con = [select ResultSnapShot__c from valuation__c WHERE Case__c =: caseId];


img=con.ResultSnapShot__c;
img=img.substringBetween('src="', '"');
//to convert unicode characters (&amp;=&)
img=img.unescapeHtml4();

SingleEmailMessage();
}

}
5
  • 1
    have you checked the debug logs ? any error you are getting ?
    – Ratan Paul
    Commented Jun 6, 2016 at 9:52
  • I did check, I get the image URL in the debug logs. By this, half of the purpose is solved. The remaining half is the mail, which isn't received.
    – Viraj
    Commented Jun 6, 2016 at 9:54
  • Have you checked the email logs? To get the email logs access Setup > Logs > Email Log Files.
    – Saroj Bera
    Commented Jun 6, 2016 at 10:51
  • check your SB email setting and set it to All emails if not already set Commented Jun 6, 2016 at 10:52
  • nothing much in the email logs guys. its empty.
    – Viraj
    Commented Jun 6, 2016 at 11:55

0

You must log in to answer this question.

Browse other questions tagged .