You need to sign in to do that
Don't have an account?

How do I change the class to be on a custom object instead of account?
How do I change the following code to be on a custom object instead of Account? And how do I have it send to the lookup account field on that object?
public class SendSiteSurveyEmailController { public String AccountId {get;set;} Public SendSiteSurveyEmailController(ApexPages.StandardController controller) { AccountId = ApexPages.currentPage().getParameters().get('Id'); } Public Pagereference SendSiteSurveyFunction() { String toaddress = 'jamore@darlingii.com'; try{ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {toaddress}; mail.setToAddresses(toAddresses); mail.setReplyTo(toaddress); mail.setSenderDisplayName('Name'); mail.setSubject('DarPro Site Survey'); mail.setBccSender(false); mail.setUseSignature(true); mail.setHtmlBody('<b> BODY </b>'); List<Messaging.EmailFileAttachment> fileAttachments = new List<Messaging.Emailfileattachment>(); for (Attachment a : [SELECT Name, Body, BodyLength FROM Attachment WHERE ParentId = :AccountId Order By LastModifiedDate DESC Limit 1]){ Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment(); efa.setFileName(a.Name); efa.setBody(a.Body); fileAttachments.add(efa); //mail.setFileAttachments(new Messaging.SingleEmailMessage[] {efa}); } mail.setFileAttachments(fileAttachments); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } catch(Exception e) {} PageReference reference = new PageReference('https://darlingingredients--griffsdbx.cs11.my.salesforce.com/a2N?fcf=00B0h000009nbs5'+AccountId); reference.setRedirect(true); return reference; } }
All Answers
VF Page:
The VF page says 'Unknown object type Site_Survey' at line 0, but there are no problems in the Controller
The name of the action was wrong, it should be SendSiteSurveyFunction NOT sendEmailFunction