PDA

View Full Version : Using Command prompt commands



mohanakannan
2nd July 2013, 14:51
Hi friends,
I want to use Command prompt commands in Qt.....Actually i'm trying to send mail via Qt...But it doesn't worked,so i have gone for some other solutions,at that time,i have found that we can send mail from command prompt and it worked too..Now i want to use that command prompt commands in Qt..It should not call Command prompt...Please any one help me.

karankumar1609
2nd July 2013, 15:08
You can use QProcess to get your commands executed.



QString program = "mkdir";
QStringList arguments;
arguments << "CreateDirectory";

QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);



CHEERS

mohanakannan
2nd July 2013, 16:19
Thanks Mr.karankumar....I'm using like this command prompt "ssmtp mohanakannan.kannan8@gmail.com <recepient1.txt"....recepient1.txt is having "from address" and "to address"...ssmtp only sends mail,i have installed it.Could you please tell me how to use it in Qt(those command prompt commands)..actually i dont have any idea....

karankumar1609
3rd July 2013, 10:13
According to you...
ssmtp mohanakannan.kannan8@gmail.com <recepient1.txt this is your command

so the code will be something like.



QString program = "ssmtp";
QStringList arguments;
arguments << "mohanakannan.kannan8@gmail.com";
arguments << "<recepient1.txt";

QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);



CHEERS

wysota
3rd July 2013, 10:31
This will not work as "<" is interpreted by a shell which is not present here.

mohanakannan
3rd July 2013, 10:56
Thank you Mr.karankumar and Mr.Wyotsa..I will try it and will tell the result..

mohanakannan
3rd July 2013, 12:56
Thanks ,
How to add the configuration file in Qt.....Actually during sending mail via command prompt,It works by means of a configure file (ssmp.conf)..It only has lot of details about AuthUser, Authpass, EnableTLS.....how to add these at all...Thats why i'm asking how to add Config file in Qt.....Thanks in advance

wysota
3rd July 2013, 13:18
This is a forum devoted to Qt, not ssmp. If you have problems with the latter, don't ask here, we have no experience with using this software.

mohanakannan
3rd July 2013, 13:34
sorry Mr.Wyotso,It is not ssmp,its "ssmtp.conf"....Its a file,i want to use that file "ssmtp.conf" in Qt...

wysota
3rd July 2013, 13:44
sorry Mr.Wyotso,It is not ssmp,its "ssmtp.conf"....
Whatever...


Its a file,i want to use that file "ssmtp.conf" in Qt...

QFile f("ssmtp.conf");
f.open(QFile::ReadOnly);
QByteArray ba = f.readAll();

mohanakannan
3rd July 2013, 16:12
Thank you very much Mr.Wysoto.....Thinking that,it will work..........Any doubts,i will ask you:)

Added after 1 49 minutes:

Hi Mr.Wyotso, I've tried your code and its working....Working in the sense,using qDebug( ),i have shown all the lines in that file.....I have told earlier that i have send the mail in command prompt using "ssmtp"...It is the only reason for sending mail...By using this command(ssmtp recipient_mail@gmail.com),it is possible....I have installed that ssmtp.....It is only having that ( ssmtp.conf ) file..Thats why i've asked how to use it. But now my problem is How to use those command ssmtp recipient_mail@gmail.com in this Qt,by that we can send mail in Qt......Thanks for your response..