void tst_QMailAddress::groupMembers()
{
    QFETCH( QString, input );
    QFETCH( QString, input_name );
    QFETCH( QString, input_address );

    QMailAddress addr;
    if ( !input.isEmpty() )
        addr = QMailAddress( input );
    else
        addr = QMailAddress( input_name, input_address );

    QTEST( addr.name(), "name" );
    QTEST( addr.address(), "address" );
    QTEST( addr.toString(), "to_string" );
    QTEST( addr.isGroup(), "is_group" );

    QStringList names, addresses;
    foreach (const QMailAddress& member, addr.groupMembers()) {
        names.append(member.name());
        addresses.append(member.address());
    }

    QTEST( names, "member_names" );
    QTEST( addresses, "member_addresses" );
}
void EmailMessage::setFrom (const QString &sender)
{
    QMailAccountIdList accountIds = QMailStore::instance()->queryAccounts(
                                       QMailAccountKey::status(QMailAccount::Enabled,
                                       QMailDataComparator::Includes), QMailAccountSortKey::name());
    // look up the account id for the given sender
    foreach (QMailAccountId id, accountIds)
    {
        QMailAccount account(id);
        QMailAddress from = account.fromAddress();
        if (from.address() == sender || from.toString() == sender ||
            from.name() == sender)
        {
            m_account = account;
            m_msg.setParentAccountId(id);
            m_msg.setFrom(account.fromAddress());
        }
    }