IMAP client and e-mail document parser for C++ Qt5
partysan e0127aac56 fix in moment | 1 ano atrás | |
---|---|---|
CurlHandle.cpp | 1 ano atrás | |
CurlHandle.h | 1 ano atrás | |
IMAPClient.cpp | 1 ano atrás | |
IMAPClient.h | 1 ano atrás | |
LICENSE | 1 ano atrás | |
MAILClient.cpp | 1 ano atrás | |
MAILClient.h | 1 ano atrás | |
README.md | 1 ano atrás | |
emaildocument.cpp | 1 ano atrás | |
emaildocument.h | 1 ano atrás | |
emaildocumententry.cpp | 1 ano atrás | |
emaildocumententry.h | 1 ano atrás | |
qtimapclient.cpp | 1 ano atrás | |
qtimapclient.h | 1 ano atrás |
IMAP client and e-mail document parser for C++ Qt5.
Dependenсies: libcurl, Qt.
A little example which will fetch all your unreaded messages with short summary:
#include "qtimapclient.h"
#include <QDebug>
#include <QThread>
int main()
{
QtImapClient imap;
imap.setConnectionType(QtImapClient::ConnectionType::SSL);
imap.setHostname("imap.server.com");
imap.setPort(993);
imap.setUsername("yournick@server.com");
imap.setPassword("IHateTheC++");
QList<unsigned int> unreaded;
if (not imap.checkUnseen(unreaded))
{
qInfo() << "Fetch failed:" << imap.errorString();
return 1;
}
qInfo() << "Unreaded emails:" << unreaded;
for (const auto& un: unreaded)
{
qInfo().noquote() << "\nFetching:" << un;
auto email = imap.fetch(un);
if (email == nullptr)
{
qInfo() << "Hmmm. Email is nullptr...";
continue;
}
qInfo() << email->from().address << email->from().name;
qInfo() << email->subject();
qInfo() << email->dateTime();
qInfo() << "Payload size:" << email->payload().size();
for (const auto& part: email->payload())
{
qInfo() << part->contentType().string << part->content().size();
}
QThread::sleep(2);
}
return 0;
}