select distinct ?r ?reqProp1
where {
  { OPTIONAL
    {
      {
        ?v1 <http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#messageSubject> ?v2 .
        ?v2 bif:contains "'Test*'" .
      } .
      FILTER(?v1=?r) .
    } .
    FILTER(!BOUND(?v1)) .
    ?r a ?v3 .
    ?v3 <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email> .
  } .
  ?r <http://akonadi-project.org/ontologies/aneo#akonadiItemId> ?reqProp1 .
}
