I'm trying to use Active Qt to modify a distribution list in Outlook. I'm able to access it and list all of its members with the following code:
QAxObject* outlook = new QAxObject("Outlook.Application");
QAxObject* session = outlook->querySubObject("Session");
QAxObject* contactsFolder = session->querySubObject("GetDefaultFolder(olFolderContacts)");
QAxObject* distList = contactsFolder->querySubObject("Items(QString)", "My contact list");
int memberCount = distList->property("MemberCount").toInt();
QAxObject* member;
for (int i = 1; i <= memberCount; i++) {
member = distList->querySubObject("GetMember(int)", i);
qDebug() << member->property("Name").toString() << " "
<< member->property("Address").toString();
delete member;
}
But when I'm trying to add a member to the list:
QAxObject* newQaxMember = session->querySubObject("CreateRecipient(QString)", "Name LastName");
IDispatch* newMember = 0;
newQaxMember->queryInterface(QUuid("00020400-0000-0000-C000-000000000046"), (void**)&newMember);
distList->querySubObject("AddMember(IDispatch*)", QVariant::fromValue(newMember));
I'm getting an error:
QAxBase::querySubObject: AddMember(IDispatch*): Error calling function or property in ({0006103C-0000-0000-C000-000000000046})
When I use dynamicCall() method instead of querySubObject(), there's no error, but also no new member appear on the list in Outlook.
What am I doing wrong?