You need to sign in to do that
Don't have an account?
chikku
Method does not exist or incorrect signature: void
I have used the constructor method but it throws an error
Error : Method does not exist or incorrect signature: void sendAnEmail() from the type sendAnEmail
Error : Method does not exist or incorrect signature: void sendAnEmail() from the type sendAnEmail
public class sendAnEmail { @InvocableMethod(label='Test' description='sends an email') public static void sendEmailWithAttachment(List<id> listofQuoteHeader) { Map<Id, Application__c> quotesMap = new Map<Id, Application__c>([SELECT id,Contact__r.Email,Contact__r.Name FROM Application__c WHERE Id IN :listofQuoteHeader]); for(Id QuoteHeaderid :listofQuoteHeader) { PageReference pref= page.PDFGEN; pref.getParameters().put('id',(Id)QuoteHeaderid); pref.setRedirect(true); system.debug('--appID-'+QuoteHeaderid); Attachment attachment = new Attachment(); Blob b=pref.getContentAsPDF(); attachment.Body = b; attachment.Name = Datetime.now().format('yyyy-MM-dd HH:mm') + ' ' + 'Quote' + '.pdf'; attachment.IsPrivate = false; attachment.ParentId = QuoteHeaderid; attachment.Name='Sign.png'; insert attachment; Messaging.SingleEmailMessage semail= new Messaging.SingleEmailMessage(); Messaging.EmailFileAttachment attach= new Messaging.EmailFileAttachment(); attach.setFileName('AttachmentEmailFile.pdf'); attach.setBody(b); semail.setSubject('Quote Issued'); // String[] emailIds= new String[]{'abc@gmail.com'}; String[] emailIds= new String[]{quotesMap.get(QuoteHeaderid)?.Contact__r.Email}; semail.setToAddresses(emailIds); semail.setPlainTextBody('Please find the attached quote details'); semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach}); Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail}); system.debug('----'+listofQuoteHeader); } SendAnEmail.sendAnEmail(); } private final Application__c account; public sendAnEmail() { system.debug('--check-'+ApexPages.currentPage().getParameters().get('QuoteHeaderid') ); try{ account = [SELECT Id, Name FROM Application__c WHERE Id = :ApexPages.currentPage().getParameters().get('QuoteHeaderid')]; } catch (Exception e) { // add your message to the user or account = new Application__c(); } } public Application__c getAccount() { return account; } }
You are a calling a non- statc (constructor) method in a static method.
Instead of line 49 --> SendAnEmail.sendAnEmail();
use this :-
new sendAnEmail();
Please mark as Best Answer so that it can help others in the future.
Regards,
Priya Ranjan