diff --git a/SoObjects/Contacts/SOGoContactFolders.m b/SoObjects/Contacts/SOGoContactFolders.m index 1caeb9c7e..424125937 100644 --- a/SoObjects/Contacts/SOGoContactFolders.m +++ b/SoObjects/Contacts/SOGoContactFolders.m @@ -507,10 +507,22 @@ Class SOGoContactSourceFolderK; - (id) contactForEmail: (NSString *) theEmail { NSArray *allContacts; + NSDictionary *contact; allContacts = [self allContactsFromFilter: theEmail excludeGroups: YES excludeLists: YES]; + contact = [allContacts lastObject]; + if (contact) + { + SOGoFolder *contactObject; + SOGoFolder *contactFolder; - return [allContacts lastObject]; + contactFolder = [self lookupName: [contact objectForKey: @"container"] inContext: context acquire: NO]; + contactObject = [contactFolder lookupName: [contact objectForKey: @"id"] inContext: context acquire: NO]; + + return contactObject; + } + + return nil; } - (NSData *) certificateForEmail: (NSString *) theEmail