You need to sign in to do that
Don't have an account?
Send Email problem
Hi all.
I'm experimenting with sending mail from APEX and have a serious problem... It isn't sent. I put the code below, but is the typical code you can find in these forums:
public class newController { public String myMessages {get{return this.myMessages;}set;} public newController (){ // 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[] {'myadress@one.com'}; String[] ccAddresses = new String[] {'otheradress@yahoo.es'}; // 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('adiez@proclientia.com'); // Specify the name used as the display name. mail.setSenderDisplayName('Salesforce Support'); // Specify the subject line for your email address. mail.setSubject('New Case Created : '); // Set to True if you want to BCC yourself on the email. mail.setBccSender(true); // 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: has been created'); mail.setHtmlBody('Your case:<b> blablabla </b>has been created<p>'+ ' View case <a href=http://www.google.es>click here</a>'); // Send the email you have created. this.myMessages = ''+Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } }
and my VF page:
<apex:page controller="newController"> {!myMessages} </apex:page>
The result:
(Messaging.SendEmailResult[getErrors=();isSuccess=true;])
thanks in advance.
adiez
Salesforce Consulting Partner in Spain
www.proclientia.com
Hi,
Try using some different email address. I have tested it using my gmail account. It is working fine for me.
Hi Naishadh,
Salesforce Consulting Partner in Spain
www.proclientia.com
trigger Contact_AU on Contact (after update) { for(Contact contacto : Trigger.new){ Contact aux = Trigger.oldMap.get(contacto.Id); Contact ct = [Select c.Title, c.SystemModstamp, c.Salutation, c.ReportsToId, c.Phone, c.OwnerId, c.OtherStreet, c.OtherState, c.OtherPostalCode, c.OtherPhone, c.OtherCountry, c.OtherCity, c.Name, c.MobilePhone, c.MasterRecordId, c.MailingStreet, c.MailingState, c.MailingPostalCode, c.MailingCountry, c.MailingCity, c.Level__c, c.LeadSource, c.LastName, c.LastModifiedDate, c.LastModifiedById, c.LastCUUpdateDate, c.LastCURequestDate, c.LastActivityDate, c.Languages__c, c.IsDeleted, c.Id, c.HomePhone, c.FirstName, c.Fax, c.EmailBouncedReason, c.EmailBouncedDate, c.Email, c.Description, c.Department, c.CreatedDate, c.CreatedById, c.Birthdate, c.AssistantPhone, c.AssistantName, c.AccountId From Contact c where c.Id = :aux.Id limit 1]; // 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[] {ct.Email}; String[] ccAddresses = new String[] {'afiugud@hotmail.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('adiez@proclientia.com'); // Specify the name used as the display name. mail.setSenderDisplayName('Salesforce Support'); // Specify the subject line for your email address. mail.setSubject('A new Professional Development order has been placed!'); // 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('Contact Name: ' + ct.Name + '/n' + 'Contact Last Name: ' + ct.LastName + '/n' + 'Contact email: ' + ct.Email + '/n' + 'Contact ID: ' + ct.Id + '/n'); mail.setHtmlBody('<p>Contact Name: ' + ct.Name + '</p>' + '<p>Contact Last Name: ' + ct.LastName + '</p>' + '<p>Contact email: <a href=\'mailto:'+ ct.Email +'\'>'+ ct.Email + '</a></p>' + '<p><hr /></p>' + '<p>Contact ID: ' + ct.Id + '</p>'); // Send the email you have created. Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } }
Salesforce Consulting Partner in Spain
www.proclientia.com