未定义的引用`CkMailMan :: put_SmtpHost(Char const *)

时间:2017-12-06 17:34:19

标签: c++ qt

我希望这个程序发送电子邮件,而我正试图用Qt

来做

emailer.h

#ifndef EMAILER_H
#define EMAILER_H

#include <QMainWindow>

namespace Ui {
class Emailer;
}

class Emailer : public QMainWindow
{
Q_OBJECT

public:
explicit Emailer(QWidget *parent = 0);
~Emailer();

private slots:
void on_pushButton_clicked();

void on_radioButton_toggled(bool checked);

void on_pushButton_2_clicked();

void ChilkatSample();

 private:
 Ui::Emailer *ui;
 };

 #endif // EMAILER_H

警告这段代码是如此灾难性,让我头疼只是为了记住我编码的内容

emailer.cpp

#include "emailer.h"
#include "ui_emailer.h"
#include <CkMailMan.h>
#include <CkEmail.h>
#include "QString"
#include <windows.h>
#include <string.h>
Emailer::Emailer(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Emailer)
{
    ui->setupUi(this);
}



Emailer::~Emailer()
{
    delete ui;
}

//Bug

void Emailer::on_pushButton_2_clicked()
{

}
//bug

CkMailMan mailman;
 bool success = mailman.UnlockComponent("test");
 CkEmail email;

void Emailer::ChilkatSample()
    {
    QString Subject = ui->label_4->text();
    QString Body = ui->label_5->text();
    QString Mailer = ui->label->text();
    std::string Subject1 = Subject.toLocal8Bit().constData();
    std::string Body1 = Body.toLocal8Bit().constData();
    std::string Mailer1 = Mailer.toLocal8Bit().constData();

    //  Set the SMTP server.
    mailman.put_SmtpHost("smtp.gmail.com");

    //  Set the SMTP login/password (if required)
    mailman.put_SmtpUsername("***");
    mailman.put_SmtpPassword("***");

    //  Create a new email object

    email.put_Subject(Subject1.c_str());
    email.put_Body(Body1.c_str());
    email.put_From("","***");
    success = email.AddTo("",Mailer1.c_str());
}
bool caca = false;
void Emailer::on_radioButton_toggled(bool checked)
{
    caca = true;
}
void Emailer::on_pushButton_clicked()
{
    if (caca == false){
        success = mailman.SendEmail(email);
    if (success != true) {

        return;
    }

    success = mailman.CloseSmtpConnection();
    if (success != true) {

    }

    }
    else if (caca == true){
        QString Days = ui->label_7->text();
         std::string Days1 = Days.toLocal8Bit().constData();
         int Days2 = std::stoi(Days1,nullptr,0);
       for (int i = 0;i == ui->label_7->text();i++){
           success = mailman.SendEmail(email);
       if (success != true) {

           return;
       }

       success = mailman.CloseSmtpConnection();
       if (success != true) {

       }


           Sleep(Days2 * 86400000);
       }
    }
}

Emailer.pro

#-------------------------------------------------
#
# Project created by QtCreator 2017-12-05T22:32:50
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = Emailer
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


SOURCES += main.cpp\
        emailer.cpp

HEADERS  += emailer.h \
    CkCrypt2.h \
    CkEmail.h \
    CkMailMan.h \
    CkObject.h \
    CkString.h

FORMS    += emailer.ui

这是输出(有趣的事实:你修复了最后一个错误BOOM 16更多错误)

输出原始:

https://pastebin.com/pMrQ3Mcr

输出:

Issues output

我有更多的头文件,其中大多数是ck的东西,他们的源可以从GitHub获取,我只需要添加#include windows.h到Ckmailman.h源

0 个答案:

没有答案