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
MargiroMargiro 

Email Address causes Error in Apex Class

Im working on a part of my class which sends an email when a form is completed. I have it up and working successfully using my email address in the code. But, the email is not supposed to go to me and when I go to change it the code wont save to server. Any help? The part of my code is below. The email address needed to be changed is in the ToAddresses string. I believe it is because of a lack of test code but Ive had no success in writing one that fixes the problem.

 

-Matt

 

 

public PageReference save() {
PageReference pdf = Page.mhformconfirm;
pdf.getParameters().put('p','p');
pdf.setRedirect(false);
Blob b = pdf.getContent();
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
email.setSubject('Conveying Application request');
String [] ToAddresses = new String[] {'margiro@piab.com'};
email.setToAddresses(ToAddresses);
email.setPlainTextBody('An order has been placed for a conveyor');
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(Lead1.company + '.pdf');
efa.setBody(b);
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
insert Lead1;
PageReference nextPage = new PageReference('/apex/mhformendpage');
nextPage .setRedirect(true);
return nextpage;
}

 

 

 

Message Edited by Margiro on 07-22-2009 10:24 AM