Set up demo projects.
This commit is contained in:
parent
06db4130d9
commit
7f8d11db2f
@ -1,11 +1,10 @@
|
|||||||
#include <QtGui/QApplication>
|
#include <QtCore>
|
||||||
|
|
||||||
#include "../src/SmtpMime"
|
|
||||||
|
|
||||||
|
#include "../../src/SmtpMime"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
// This is a first demo application of the SmtpClient for Qt project
|
// This is a first demo application of the SmtpClient for Qt project
|
||||||
|
|
||||||
@ -44,9 +43,21 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Now we can send the mail
|
// Now we can send the mail
|
||||||
|
|
||||||
smtp.connectToHost();
|
if (!smtp.connectToHost()) {
|
||||||
smtp.login();
|
qDebug() << "Failed to connect to host!" << endl;
|
||||||
smtp.sendMail(message);
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!smtp.login()) {
|
||||||
|
qDebug() << "Failed to login!" << endl;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!smtp.sendMail(message)) {
|
||||||
|
qDebug() << "Failed to send mail!" << endl;
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
smtp.quit();
|
smtp.quit();
|
||||||
|
|
||||||
}
|
}
|
29
demos/demo1/demo1.pro
Normal file
29
demos/demo1/demo1.pro
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2014-10-30T22:19:03
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core
|
||||||
|
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
TARGET = demo1
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
demo1.cpp
|
||||||
|
|
||||||
|
# Location of SMTP Library
|
||||||
|
SMTP_LIBRARY_LOCATION = $$PWD/../../../build/SMTPEmail-Desktop-Debug
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$SMTP_LIBRARY_LOCATION/release/ -lSMTPEmail
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$SMTP_LIBRARY_LOCATION/debug/ -lSMTPEmail
|
||||||
|
else:unix: LIBS += -L$$SMTP_LIBRARY_LOCATION -lSMTPEmail
|
||||||
|
|
||||||
|
INCLUDEPATH += $$SMTP_LIBRARY_LOCATION
|
||||||
|
DEPENDPATH += $$SMTP_LIBRARY_LOCATION
|
@ -14,12 +14,11 @@
|
|||||||
See the LICENSE file for more details.
|
See the LICENSE file for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui/QApplication>
|
#include <QtWidgets>
|
||||||
|
|
||||||
#include "sendemail.h"
|
#include "sendemail.h"
|
||||||
#include "../../src/SmtpMime"
|
#include "../../src/SmtpMime"
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
32
demos/demo2/demo2.pro
Normal file
32
demos/demo2/demo2.pro
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2014-10-30T22:48:32
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core gui
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
TARGET = demo2
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
demo2.cpp \
|
||||||
|
sendemail.cpp
|
||||||
|
|
||||||
|
# Location of SMTP Library
|
||||||
|
SMTP_LIBRARY_LOCATION = $$PWD/../../../build/SMTPEmail-Desktop-Debug
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$SMTP_LIBRARY_LOCATION/release/ -lSMTPEmail
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$SMTP_LIBRARY_LOCATION/debug/ -lSMTPEmail
|
||||||
|
else:unix: LIBS += -L$$SMTP_LIBRARY_LOCATION -lSMTPEmail
|
||||||
|
|
||||||
|
INCLUDEPATH += $$SMTP_LIBRARY_LOCATION
|
||||||
|
DEPENDPATH += $$SMTP_LIBRARY_LOCATION
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
sendemail.h
|
||||||
|
|
||||||
|
FORMS += \
|
||||||
|
sendemail.ui
|
@ -123,7 +123,7 @@ void SendEmail::on_sendEmail_clicked()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox okMessage (this);
|
QMessageBox okMessage (this);
|
||||||
okMessage.setText("The email was succesfully sended.");
|
okMessage.setText("The email was succesfully sent.");
|
||||||
okMessage.exec();
|
okMessage.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2011 - Tőkés Attila
|
|
||||||
|
|
||||||
This file is part of SmtpClient for Qt.
|
|
||||||
|
|
||||||
SmtpClient for Qt is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
SmtpClient for Qt is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY.
|
|
||||||
|
|
||||||
See the LICENSE file for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <QtGui/QApplication>
|
|
||||||
#include "../src/SmtpMime"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
QApplication a(argc, argv);
|
|
||||||
|
|
||||||
// First create the SmtpClient object and set the user and the password.
|
|
||||||
|
|
||||||
SmtpClient smtp("smtp.gmail.com", 465, SmtpClient::SslConnection);
|
|
||||||
|
|
||||||
smtp.setUser("your_email@gmail.com");
|
|
||||||
smtp.setPassword("your_password");
|
|
||||||
|
|
||||||
// Create a MimeMessage
|
|
||||||
|
|
||||||
MimeMessage message;
|
|
||||||
|
|
||||||
message.setSender(new EmailAddress("your_email@gmail.com", "Your Name"));
|
|
||||||
message.addRecipient(new EmailAddress("recipient@host.com", "Recipient's Name"));
|
|
||||||
message.setSubject("SmtpClient for Qt - Demo");
|
|
||||||
|
|
||||||
// Add some text
|
|
||||||
MimeText text;
|
|
||||||
text.setText("Hi!\n This is an email with some attachments.");
|
|
||||||
message.addPart(&text);
|
|
||||||
|
|
||||||
// Now we create the attachment object
|
|
||||||
MimeAttachment attachment (new QFile("image1.jpg"));
|
|
||||||
|
|
||||||
// the file type can be setted. (by default is application/octet-stream)
|
|
||||||
attachment.setContentType("image/jpg");
|
|
||||||
|
|
||||||
// Now add it to message
|
|
||||||
message.addPart(&attachment);
|
|
||||||
|
|
||||||
// Add an another attachment
|
|
||||||
message.addPart(new MimeAttachment(new QFile("document.pdf")));
|
|
||||||
|
|
||||||
// Now we can send the mail
|
|
||||||
|
|
||||||
smtp.connectToHost();
|
|
||||||
smtp.login();
|
|
||||||
smtp.sendMail(message);
|
|
||||||
smtp.quit();
|
|
||||||
|
|
||||||
}
|
|
28
demos/demo3/demo3.pro
Normal file
28
demos/demo3/demo3.pro
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2014-10-30T22:20:42
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core
|
||||||
|
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
TARGET = demo3
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
demo3.cpp
|
||||||
|
|
||||||
|
# Location of SMTP Library
|
||||||
|
SMTP_LIBRARY_LOCATION = $$PWD/../../../build/SMTPEmail-Desktop-Debug
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$SMTP_LIBRARY_LOCATION/release/ -lSMTPEmail
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$SMTP_LIBRARY_LOCATION/debug/ -lSMTPEmail
|
||||||
|
else:unix: LIBS += -L$$SMTP_LIBRARY_LOCATION -lSMTPEmail
|
||||||
|
|
||||||
|
INCLUDEPATH += $$SMTP_LIBRARY_LOCATION
|
||||||
|
DEPENDPATH += $$SMTP_LIBRARY_LOCATION
|
@ -14,12 +14,13 @@
|
|||||||
See the LICENSE file for more details.
|
See the LICENSE file for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui/QApplication>
|
#include <QtCore>
|
||||||
#include "../src/SmtpMime"
|
|
||||||
|
#include "../../src/SmtpMime"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
// First create the SmtpClient object and set the user and the password.
|
// First create the SmtpClient object and set the user and the password.
|
||||||
|
|
||||||
@ -36,7 +37,6 @@ int main(int argc, char *argv[])
|
|||||||
message.addRecipient(new EmailAddress("recipient@host.com", "Recipient's Name"));
|
message.addRecipient(new EmailAddress("recipient@host.com", "Recipient's Name"));
|
||||||
message.setSubject("SmtpClient for Qt - Example 3 - Html email with images");
|
message.setSubject("SmtpClient for Qt - Example 3 - Html email with images");
|
||||||
|
|
||||||
|
|
||||||
// Now we need to create a MimeHtml object for HTML content
|
// Now we need to create a MimeHtml object for HTML content
|
||||||
MimeHtml html;
|
MimeHtml html;
|
||||||
|
|
||||||
@ -63,10 +63,21 @@ int main(int argc, char *argv[])
|
|||||||
message.addPart(&image2);
|
message.addPart(&image2);
|
||||||
|
|
||||||
// Now the email can be sended
|
// Now the email can be sended
|
||||||
|
if (!smtp.connectToHost()) {
|
||||||
|
qDebug() << "Failed to connect to host!" << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!smtp.login()) {
|
||||||
|
qDebug() << "Failed to login!" << endl;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!smtp.sendMail(message)) {
|
||||||
|
qDebug() << "Failed to send mail!" << endl;
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
smtp.connectToHost();
|
|
||||||
smtp.login();
|
|
||||||
smtp.sendMail(message);
|
|
||||||
smtp.quit();
|
smtp.quit();
|
||||||
|
|
||||||
}
|
}
|
28
demos/demo4/demo4.pro
Normal file
28
demos/demo4/demo4.pro
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2014-10-30T22:20:54
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core
|
||||||
|
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
TARGET = demo4
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
demo4.cpp
|
||||||
|
|
||||||
|
# Location of SMTP Library
|
||||||
|
SMTP_LIBRARY_LOCATION = $$PWD/../../../build/SMTPEmail-Desktop-Debug
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$SMTP_LIBRARY_LOCATION/release/ -lSMTPEmail
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$SMTP_LIBRARY_LOCATION/debug/ -lSMTPEmail
|
||||||
|
else:unix: LIBS += -L$$SMTP_LIBRARY_LOCATION -lSMTPEmail
|
||||||
|
|
||||||
|
INCLUDEPATH += $$SMTP_LIBRARY_LOCATION
|
||||||
|
DEPENDPATH += $$SMTP_LIBRARY_LOCATION
|
Loading…
Reference in New Issue
Block a user