function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
souvik9086souvik9086 

PROBLEM IN MASS EMAIL SENT WITH PDF ATTACHMENT

Hi,

     Yes I have tried the way u have said and changed the code in this way

public pageReference SendEmail()
            {    
                     System.Debug('############Size of unselected############'+selectedNames.size());
                     Id quoteid = ApexPages.currentPage().getParameters().get('quoteid');
                     quote1 = [select id,name from Quote where id =:quoteid];
                     PageReference pdfPage = Page.convertpdf1;
                     pdfPage.getParameters().put('id',quoteid);
                     Blob pdfBlob = pdfPage.getContent();
                     Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
                     efa.setFileName('attachment.pdf');
                     efa.setBody(pdfBlob);  
                     
                     Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                   
                     for (String obj : selectedNames)
                     {
                         contact = [select Id,name,email from Contact where name =:obj];
                        //id1 = new List<Id>();
                         for(Integer i=0; i < contact.size(); i++)
                             {
                                 email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
                                 //id1.add(contact[i].Id);
                                 email.setTargetObjectId(contact[i].Id);
                                 email.setTemplateId(e1.id);
                                 Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
                             }  
                     visible = 'show';
                     return null;
              }

The apex class is saved. But while sending mass mail there is a visualforce error

List has no rows for assignment to SObject .

 

Plz provide the exact code if possible.

Arijit_rArijit_r

The problem is in the query statement:

 

contact = [select Id,name,email from Contact where name =:obj];

 

Please make sure a contact exist in SFDC db with the name hold by the variable obj. Additionaly you need to handle any exceptions thrown in the code.