You need to sign in to do that
Don't have an account?
Inbox Outbox
Greetings!
I need help in writing a code to send email both single and mass email with LWC and apex both? Please correct me and advice me.
I want to be able to create a custom component where we can attach a file (template) and send it.
I also want to write a trigger with/without a helper class to be able to send a mass email.
Any use case is fine, please mention the use case so that my silly brain can co-relate.
I want to be able to create a custom component where we can attach a file (template) and send it.
I also want to write a trigger with/without a helper class to be able to send a mass email.
Any use case is fine, please mention the use case so that my silly brain can co-relate.
Hi
Please refer this article which will help you to achieve your requirement :-
https://github.com/MrRajatSharma/Lightning-web-component-send-email
https://webkul.com/blog/sending-email-apex/
https://developer.salesforce.com/forums/?id=9060G000000I7kUQAS
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm
Please mark it as Best Answer so that it can help others in the future.
Regards,
Priya Ranjan
All Answers
Hi
Please refer this article which will help you to achieve your requirement :-
https://github.com/MrRajatSharma/Lightning-web-component-send-email
https://webkul.com/blog/sending-email-apex/
https://developer.salesforce.com/forums/?id=9060G000000I7kUQAS
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_forcecom_email_outbound.htm
Please mark it as Best Answer so that it can help others in the future.
Regards,
Priya Ranjan
I have the following code with an error. Please advice!
class:
public class massEmail
{
public void mail(){
list<contact> l= [SELECT ID FROM contact LIMIT 2];
list<ID> I= new list<ID>();
for(contact c: l){
I.add(C.Id);
}
EmailTemplate e = [SELECT ID FROM EmailTemplate WHERE Name = 'Sales: New Customer Email'];
messaging.MassEmailMessage m = new messaging.MassEmailMessage();
m.setTargetObjectIds(I);
m.setSenderDisplayName('System Admin');
m.setTemplateId(e.Id);
messaging.sendEmail(new messaging.MassEmailMessage [] {m});
}
}
Trigger:
trigger NewCustEmail on Contact (after insert)
{
if(trigger.IsAfter){
massEmail.mail(trigger.new);
}
}
Error:
Method does not exist or incorrect signature: void email(List<Contact>) from the type massEmail
Hi ,
1. You need to make your method static like
2.You are not passing the argument in your method "mail()" but you are sending an argument from trigger "massEmail.mail(trigger.new);" . It is mandatory to pass argument in the method.
so you can correct your whole code like this:
Please mark it as Best Answer
Thank You