Hello all! First I want to thank all of you. This information has been very helpful. With some minor modifications, I am now able to send an email via SMTP. The code that I am using was pasted from this forum and tweaked to get it to work with Qt4.6.2.
I am having one issue though - my body text never gets transferred! What is happening? I get a subject line, but no body text. My ultimate goal is to attach a file, but I am a bit worried about accomplishing that if I cannot even get my body text to show up!
It is this part of the code that I really do not understand. 1) Does it have to be done in this manner? 2) What is the purpose of the replaces? 3) How is SMTP getting my Subject Text, but not my Body Text? Any help is appreciated. (P.S. I am going to post this on another thread in order to make sure it gets seen).
...
sMessage = "To: " + to + "\n";
sMessage.append("From: " + from + "\n");
sMessage.append("Subject: " + subject + "\n");
sMessage.append(body);
sMessage.
replace( QString::fromLatin1( "\n" ),
QString::fromLatin1( "\r\n" ) );
sMessage.
replace( QString::fromLatin1( "\r\n.\r\n" ),
QString::fromLatin1( "\r\n..\r\n" ) );
sFrom = from;
sTo = to;
...}
Smtp::Smtp( const QString &from, const QString &to, const QString &subject, const QString &body ) {
...
sMessage = "To: " + to + "\n";
sMessage.append("From: " + from + "\n");
sMessage.append("Subject: " + subject + "\n");
sMessage.append(body);
sMessage.replace( QString::fromLatin1( "\n" ), QString::fromLatin1( "\r\n" ) );
sMessage.replace( QString::fromLatin1( "\r\n.\r\n" ), QString::fromLatin1( "\r\n..\r\n" ) );
sFrom = from;
sTo = to;
...}
To copy to clipboard, switch view to plain text mode
Bookmarks