You need to sign in to do that
Don't have an account?
Kruvi
Sending an email on a click of a button
Hi
I have an Invoice object and I want to create a button that on-click will send an email with the related Invoice information to the customer.
I have created an email template for this but I'm not sure how to write the APEX code such that when I mark an Invoice and press the button an email will be sent to the contact designated in the invoice including the rest of the detailes in the invoice.
If not APEX is there any other way to achieve the same?
Thanks
try this one. It will work
Let me know if you need any more help
Cheers,
Bala
All Answers
I would recommend a "Custom Link", since you're just using basic information. Apex Code can also send the email, but that's akin to using an elephant gun on a mouse. Setup > Create > Objects > Inventory > Custom Buttons & Links > New
The URL is:
Where 00XX0000000XXXX is the email template to use.
hiii
it may possible with vf page and apex class
try it
Cool, I'll try it now using a custom link.
Will this method with a custom link also allow me to mark multiple invoices and send them?
Many Thanks
Thank you for the idea, I got the EmailAuthor to work but this takes me to a page where I have to put additional email addresses and press send.
I have many such invoices to email. Is there any way to automate this?
Thanks
ok,
we will automate your functionality with just one click. we can achive this by Workflow + Email Alert Combination
Here is approach
**** be careful --
replace Invoice__c by your custom Invoice object name
Create new boolean field with same API name SendEmail__c
This will send Email every single Invoice information to particulars
If you want to send Emails to multiple invoice at one click , we need to embed same logic for multiple records
Hope This will help you
Thanks,
Bala
Thank you, cool idea, I got it to work.
But, when I try to write a for loop for it I get an "Unexpected end of input" message and I do not know why.
Any idea?
Thanks
Nice to heard that first part works for you.
Are you trying to implement same for multiple records ? (by using List Button )
If so please post the script code. we will check out
Cheers,
Bala
I think my problem is in the for loop but I'm not sure
This is what I wrote:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
{!REQUIRESCRIPT("/js/functions.js")}
sforce.debug.trace=true;
var records = {!GETRECORDIDS( $ObjectType.Invoice__c )};
if(records[0] == null){
alert("Please select at least one record.")
}
else{
try{
for(var i=0; i<records.length; i++) {
var objInvoice = new sforce.SObject("Invoice__c");
objInvoice.Id = records[i].Id;
objInvoice.Email_Invoice__c=true;
var saveRes=sforce.connection.update([objInvoice]);
}
if (saveRes[0].success=='false'){
alert(saveRes[0].errors.message);
}
}
catch(error){
alert("Error while Sending Email:=="+error);
}
try this one. It will work
Let me know if you need any more help
Cheers,
Bala
Many thanks
It works perfectlly
Hi guys,
I know this is a very old post but since it has helped me a big deal, i would like to ask for help on this. I have implemented something close to this and it works fine.However, after clicking my Custom List button to send the email, an AJAX Toolkit Shell box pops up.How do i get to prevent it from popping up or hide it entirely?
Thanks in advance.
comment this line out like this:
//sforce.debug.trace=true;
Hi Kruvi,
Thanks alot,that worked. One more last thing though,how do i make it show its processing or proof that its sending since there is no any form of processing taking place shown to the user after clicking the send button either by atleast loading the page again with the selected records unselected or atleast something to show the user that the sending has taken place.As well as having the sent mail shown in the Activity History of the Record.
Thanks in advance.
Well, I guess there are a few ways to do that.
You can save the result of the operation and based on that you can alert the user:
You can refresh the window by adding this to the JS:
Nice solution sfdcfox, very clean and simple for one-off templated emails.
Niki
www.vankerksolutions.com