PDA

View Full Version : [Qxt] Ho to send attachment with html message ?



slimittn
20th December 2010, 16:10
Hi,

i tried to use qxt to send mails through smtp. I succeed to send html mails and plain text mails with attachment but when i try to send html mails with attachments i receive a message like this :



This is a message with multiple parts in MIME format.
--0d51120e-3412-43ca-9171-655ece0d0011
Content-Type: text/html

<html><body><h1 style="text-align: center;">Safe Systems</h1></body></html>
--0d51120e-3412-43ca-9171-655ece0d0011
Content-Disposition: attachment; filename=flyer1.png
Content-Type: image/png
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAAb0AAAKYCAYAAADnpyZcAAAAAX NSR0IArs4c6QAAAAZiS0dEAP8A..........


this is my script :



QFile flyer("flyer1.png");
flyer.open(QIODevice::ReadOnly);
QxtMailAttachment *attachment = new QxtMailAttachment(flyer.readAll(),QString("image/png"));

QxtMailMessage *message = new QxtMailMessage;
message->setSender("Sender Mail <xxx@xxx.tn>");
message->setExtraHeader("Reply-To","xxx@xxx.fr");
message->addRecipient("xcv@qsd.com");
message->setSubject("Test subject.");

message->setExtraHeader("Content-Type","text/html");
message->setBody(QByteArray("<html><body><h1 style=\"text-align: center;\">Test Mail</h1></body></html>"));

message->setExtraHeader("MIME-Version","1.0");
message->addAttachment("flyer1.png",*attachment);

QxtSmtp *smtp = new QxtSmtp;
smtp->connectToHost("smtp.xx.yy");
smtp->send(*message);



How can i fix this ?

Thanks.

bapi23
23rd May 2011, 14:20
Hi!
This works fine with *jpg files - look for you content type...

Morion_self
18th June 2011, 22:38
Hi!

Why I get error messages (like this: undefined reference to `QxtMailMessage::QxtMailMessage()') in this part of code:

QxtMailMessage *message = new QxtMailMessage;

I write in my h-file
#include <QxtNetwork/qxtsmtp.h>
#include <QxtNetwork/qxtmailmessage.h>

I use Qt Creator 2.0.1, if it is important

stampede
18th June 2011, 22:59
Sounds like a linker error. I've never used Qxt, but probably you'll need to add -lqxt or something like that to compilation options ( check Qxt webpage or README for details ).

Morion_self
18th June 2011, 23:19
No, not at the site or in the readme is nothing like that

P.S. I think, I must write
#include <QxtMailMessage>
but if I do it, I get error: QxtMailMessage: No such file or directory

d_stranz
18th June 2011, 23:42
An "undefined reference" is a linker error not a compile error. It has absolutely nothing to do with header files. It means that you have not specified the library that contains the QxtMailMessage object code during the linking of your program.

stampede
18th June 2011, 23:42
Here is Qxt User Guide (http://dev.libqxt.org/libqxt/wiki/user_guide), there is "Using Qxt in your project" section.

Morion_self
19th June 2011, 00:01
Oh, thanks...

I used only
QXT += core gui
as an example.. bad English =))