PDA

View Full Version : Command prompts in qt



mohanakannan
10th July 2013, 15: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, 16:03
https://github.com/bluetiger9/SmtpClient-for-Qt/wiki

http://www.qtcentre.org/threads/44483-SMTP-Client-for-Qt

http://www.qtcentre.org/threads/2221-Sending-email-using-Qt

http://blog.wysota.eu.org/index.php/2009/05/13/qwwsmtpclient-released/

mohanakannan
10th July 2013, 16: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, 17:44
I don't think the first link uses it. Try to read more about it.

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

mohanakannan
12th July 2013, 11: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);

smtp.setUser("your_email_address@gmail.com");
smtp.setPassword("your_password");

// 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.");
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();

}

karankumar1609
12th July 2013, 14:08
Your same thread is already exists
http://www.qtcentre.org/threads/55244-Using-Command-prompt-commands?p=247097&highlight=#post247097

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

mohanakannan
12th July 2013, 14: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, 22:28
Did you download and put SmtpClient src folder and place in appropriate path?, if not you need to do so.