// Get the selected user from the form
selectedUser = input.Meeting_With;
// Fetch the email of the selected user from the User list
attendeeEmailList = Users[Full_Name == selectedUser];
// Check if a valid email was found
if(attendeeEmailList.count() > 0)
{
attendeeEmail = attendeeEmailList.get(0).Email;
// Sending the email
sendmail = Map();
sendmail.put("to",attendeeEmail);
sendmail.put("subject","New Visitor Registration");
sendmail.put("message","Hello " + selectedUser + ",\n\nA new visitor has registered for a meeting:\n\nName: " + input.Name + "\nContact Number: " + input.Contact_Number + "\nPurpose of Visit: " + input.Purpose + "\n\nPlease be prepared to meet them.\n\nThank you,\nFoxivision");
zoho.creator.mail(sendmail);
}
else
{
info "No valid attendee email found for " + selectedUser;
}