我想用Qt發送一封簡單的電子郵件。我嘗試了很多庫,但我發現最簡單的庫是chilkat庫。這裏是我的代碼...QT中的奇爾卡特錯誤(C++)
CkMailMan mailman;
bool success = mailman.UnlockComponent("xxxxxxxxxxxxx");
if (success != true) {
qDebug() << mailman.lastErrorText() << "\r\n";
return;
}
mailman.put_SmtpHost("smtp.gmail.com");
mailman.put_SmtpUsername("[email protected]");
mailman.put_SmtpPassword("xxxxxxxxxxxxxxxxxxx");
CkEmail email;
QString body = "xxxxxxxxxxxxxxxxxxxx";
QByteArray ba = body.toLatin1();
const char *c_str2 = ba.data();
email.put_Subject("xxxxxxxxxxxxxxxx");
email.put_Body(c_str2);
email.put_From("xxxxxxxxxxxxxx");
success = email.AddTo("xxxxxxxxxxx","[email protected]");
success = mailman.SendEmail(email);
if (success != true) {
qDebug() << mailman.lastErrorText() << "\r\n";
return;
}
success = mailman.CloseSmtpConnection();
if (success != true) {
qDebug() << "Connection to SMTP server not closed cleanly." <<
"\r\n";
}
qDebug() << "Mail Sent!" << "\r\n";
這裏是錯誤... error: cannot find -lChilkatDbg_x64d
編輯: .pro文件:
#-------------------------------------------------
#
# Project created by QtCreator 2017-05-20T16:57:12
#
#-------------------------------------------------
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = WoW_Free_Gold
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
HEADERS += mainwindow.h \
FORMS += mainwindow.ui
RESOURCES += \
resources.qrc
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/chilkat-9.5.0-x86_64-
vc2017/libs/ -lChilkatDbg_x64
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/chilkat-9.5.0-
x86_64-vc2017/libs/ -lChilkatDbg_x64d
else:unix: LIBS += -L$$PWD/chilkat-9.5.0-x86_64-vc2017/libs/ -
lChilkatDbg_x64
INCLUDEPATH += $$PWD/chilkat-9.5.0-x86_64-vc2017/include
DEPENDPATH += $$PWD/chilkat-9.5.0-x86_64-vc2017/include
DISTFILES += \
chilkat-9.5.0-x86_64-vc2017/libs/ChilkatDbg_x64.lib \
chilkat-9.5.0-x86_64-vc2017/libs/ChilkatDbgDll_x64.lib \
chilkat-9.5.0-x86_64-vc2017/libs/ChilkatRel_x64.lib \
chilkat-9.5.0-x86_64-vc2017/libs/ChilkatRelDll_x64.lib
我怎樣才能使這項工作? 感謝所有...
顯示如何編譯您的項目和您的.pro文件 – eyllanesc
https://pastebin.com/t2FcXeKG –
不要發佈鏈接,[編輯](https://stackoverflow.com/帖子/ 44123064 /編輯)你的問題,並添加它 – eyllanesc