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
vivek ravivivek ravi 

how to send the notes title and body of custom record to paricular email

Hi I need to send the custom object record Notes Title and Body to the particular mail id my code
public with sharing class mail
{
public mail(ApexPages.StandardController controller)
{
string save=ApexPages.currentPage().getParameters().get('id');
List<NotesAndAttachments> n=[Select Title,Body From Brand__c.NotesAndAttachments Where parentid='01Ii0000001aNoy']; 
}  

public PageReference Send()
{
   
    String[]address=new String[] {sinffer@gmai.com'}; 
    Messaging.SingleEmailMessage emails = new Messaging.SingleEmailMessage();
    emails.setTargetObjectId('005i0000002nxZ6');
    emails.setTemplateId('00Xi0000000J9hx');
    emails.SaveAsActivity=(false);
    emails.setsubject('Simple Subject');
    emails.setplaintextbody('simple');
    emails.setToAddresses(address);
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emails });
  

   
    return null;
   
}

when im using this code im getting error like this ::First SObject of the FROM statement must be a valid SObject type. at line 11 column 29

can any one help out from this
Vinita_SFDCVinita_SFDC
Hello,

I don't understand your requirement properly, are there fields with the name Title and Body in a custom object which you wish to refer in email?

If yes, then you can achieve this by using merge fields. Refer: https://help.salesforce.com/HTViewHelpDoc?id=merge_fields_email_templates.htm&language=en_US
vivek ravivivek ravi
Hi vinita
Thanks for ur reference link but my requeriment is i just need to take the notes and attachment which we have in related list fields that i want to fetch it with my mail which im going to send . title and body is not in my object field its in notes and attachment field that i wan to send 
Vinita_SFDCVinita_SFDC
Hi,

With standard functinality it is not possible and there is an idea for the same on ideaexchange. Please refer following thread addressing similar requirement:

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008yN4IAI

Idea link: https://success.salesforce.com/ideaView?id=08730000000BpSJAA0
vivek ravivivek ravi
i have checked this link
Thanks for your reference vinita