View Full Version : Command prompts in qt

10th July 2013, 14:33
Hi friends,
I want to send mail in Qt…For that i have gone through many sites and forums and cant able to get a clear picture……On that way,i have found that ,through command prompt commands,we can send email with attachments etc…..Did anyone know,how to use those command prompt commands in Qt to send mail.I have been strucking in this for more than 20 days..Or is there any other options to send mail in Qt without command prompt commands……Please help me..

Santosh Reddy
10th July 2013, 15:03




10th July 2013, 15:30
Thank you Mr. SanthoshReddy,
I have gone through all these things,which you have provided.........In each thing,it is saying only one thing,STARTTLS command is needed......I'm a newbie...I cant able to sought out the problem....Please kindly help me..

Santosh Reddy
10th July 2013, 16:44
I don't think the first link uses it. Try to read more about it.

11th July 2013, 11:00
You can use QProcess to execute command prompt commands..

12th July 2013, 10:48
thanks mr.karankumar ...
i'm using this command "sendemail -f fromuser@gmail.com -t touser@domain.com -u subject -m "message" -s smtp.gmail.com -o tls=yes -xu gmailaccount -xp gmailpassword "........how to use this in qt...i have tried to put whole thing in the start(.........).
but it is showing error..how to proceed.Thanks in advance

Added after 18 minutes:

thanks mr.santhosh reddy...
i got the error SmtpMime has no such directory...When i run this below code

#include <QtGui/QApplication>
#include "../src/SmtpMime"-------------------------------------------->ERROR:No such file or directory...

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);


// Create a MimeMessage

MimeMessage message;

message.setSender(new EmailAddress("your_email_address@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.");

// Now we create the attachment object
MimeAttachment attachment (new QFile("image1.jpg"));

// the file type can be setted. (by default is application/octet-stream)

// Now add it to message

// Add an another attachment
message.addPart(new MimeAttachment(new QFile("document.pdf")));

// Now we can send the mail



12th July 2013, 13:08
Your same thread is already exists

Now you have to google "How to use QProcess" and learn about it.
Or Go through to QProcess class.
It will help you..

12th July 2013, 13:12
thanks mr.KarannKumar,
Ya i forgot to tell in that thread...I have tried using QProcess,,,but it doesn't send anything....When i use qDebug to know what it carries,it simply displays some 0x233323,some thing like that...It never send anything...

Santosh Reddy
12th July 2013, 21:28
Did you download and put SmtpClient src folder and place in appropriate path?, if not you need to do so.