Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(‘test.pdf’); //File Name
efa.setBody(someFile);
efa.setContentType(‘application/pdf’); // File type
email.setSubject( ‘adada’ );
email.setToAddresses( new String[] {‘[email protected]’} ); // List of email ids.
email.setPlainTextBody( ‘Tjis is test’ );
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
Consideration for enabling manual sharing in Salesforce
Consideration for enabling manual sharing in Salesforce

To do Manual Sharing:
- The person must be one of the following users. (Record level permission)
- The record owner.
- A user in a role above the owner in the hierarchy.
- Any user granted Full Access to the record. (Modify all data access permission to the object)
- An administrator
- You should have at least read/write access to the object. (Object level permission)
- OWD should be private or public read-only.
- Sharing is not available on child record if OWD is “controlled by parent” in case of Master-detail.
- Sharing button should be on the layout.
- “Manual User Record Sharing” must be true, this is a checkbox inside Sharing setting under edit option of OWD.
Bonus: Salesforce removes all manual sharing from a record when the owner changes. Ex: Tom owns account “Google” and shared the record (Google) with Tina and Lisa with edit access. Later ownership of “Google” account is changed from Tom to Mike. Tina and Lisa will lose their access to the “Google” account.
Searches related to Consideration for enabling manual sharing in Salesforce
account sharing rules salesforce
sharing rules in salesforce examples
sharing settings in Salesforce
apex sharing trailhead
recalculating sharing rules salesforce
salesforce sharing settings not working
salesforce sharing model
conditional sharing salesforce