Accessing related items such as emails via custom functions
I have written a custom function which converts a Contact into a custom module (called "Students" in my CRM). This searches contacts by id, uses a map to access the field values of the result contact and populates a new Student record with that information. Then, it deletes the original Contact. So, I go from having a Contact record filled with info, to having just a Student record filled with all the same info.
I now need to add some functionality to this custom function which accesses anything in the related lists of the original contact (emails etc), and add these to the newly created Student record.
For example, when you convert a lead to a contact, any emails that have been sent via Zoho to that lead will be copied over to the new contact record. My custom function needs to replicate this.
Any ideas?