You need to sign in to do that
Don't have an account?
sales4ce
How to send email from a custom button
Hi,
I want to send an email after my user clicks on the "Send email" custom button.
How do i trigger email after click.Serached through some of the posts, but to no luck.
Can any one help/point me in right direction.
Thanks,
Sales4ce
Custom buttons can reference content of OnClick JavaScript, Visualforce Pages, etc.
From your Javascript or Visualforce Page, you can do a webservice call to an APEX class to send the emails for you.
Check out the information about APEX Web Services: http://wiki.developerforce.com/index.php/Apex_Web_Services_and_Callouts
There may be a simpler approach, but this solution is what comes to mind.
Hi ,
You can call action method in your Controller and you can write the Code for sending for Email.
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
/* Strings to hold the email addresses to which you are sending the email.*/
String[] toAddresses = new String[] {'test@abc.com'};
String[] ccAddresses = new String[] {'test1@abc.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('test2@abc.com');
// Specify the name used as the display name.
mail.setSenderDisplayName('Sample Email);
// Specify the subject line for your email address.
mail.setSubject(subject);
// Set to True if you want to BCC yourself on the email.
mail.setBccSender(bccSender);
// 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(body);
mail.setHtmlBody(body);
// Send the email you have created.
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
Regards,
Mohammed Junaid
I was searching for something similiar and found the link below. Just as an alternative to the above.
Works very well for me!
https://sites.secure.force.com/blogs/ideaView?c=09a30000000D9xo&id=087300000006tqz&returnUrl=%2Fapex%2FideaList%3Fc%3D09a30000000D9xo%26category%3DSalesforce%2BCRM#comments