You need to sign in to do that
Don't have an account?
Outbound E-mail
I'm starting working with e-mails through Force.com.
Following is the code I'm running. The strange issue is that the success to send an e-mail depends on the text.
First I tried to send only a message written in the body1 variable without success. Only adding an extra character I succeed to send the e-mail.
// 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[] {'gustavopipman@hotmail.com'};//String[] ccAddresses = new String[] {'smith@gmail.com'};// 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('gustavopipman@hotmail.com');// Specify the name used as the display name.mail.setSenderDisplayName('Gustavo Tests');// Specify the subject line for your email address.mail.setSubject('E-mail test 12');// 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.String body1='eka';String body2='Eur';mail.setPlainTextBody(body2+ body1);//mail.setHtmlBody('Your case:<b> ' + case.Id +' </b>has been created<p>'+//' View case <a href=https://na1.salesforce.com/'+case.Id+'>click here</a>');// Send the email you have created.Messaging.sendEmailResult[] r=Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });system.debug(r[0].isSuccess());
I have tried as mentioned below and it worked fine at my end :
String body1='Eureka';
mail.setPlainTextBody(body1);