PDA

View Full Version : Qt Messaging



Lili Tagetes
28th September 2011, 07:47
Hi! I'm writing one program for sending email. I saw some examples and took next code from one

QMessageService service;
bool b;


QString accountName("111@gmail.com");
QMessage message;
message.setType(QMessage::Email);
message.setParentAccountId(QMessageAccountId(accou ntName));

QString to("222@gmail.com");
QMessageAddress addr(QMessageAddress::Email,to);
message.setTo(addr);

QString subject("first message");
message.setSubject(subject);

QString text("Hello");
message.setBody(text);

b = message.parentAccountId().isValid();
if (service.send(message))
{
QMessageBox::information(0,tr("Success"),tr("Email sent successfully!"));
hide();
}
else
{
QMessageBox::warning(0, tr("Failed"), tr("Unable to send message. Valid: %1").arg(b));

}

When i try to send message on my device it all the times say me "Unable to send message.Valid: 1". I don't know where can be mistake...should you give me any ideas?

high_flyer
28th September 2011, 15:40
Looks like the parentAccountId you are setting is not valid.

Lili Tagetes
28th September 2011, 19:48
should you tell me, what kind it must be? and b = 1 so it's valid, isn't it?

high_flyer
30th September 2011, 16:29
and b = 1 so it's valid, isn't it?
Yes, sorry, I read you post to quickly.
This means that service.send() failed:

Returns true if the operation can be initiated; otherwise returns false.

I am don't really know about mobility.
Maybe the problem is not in the code, but maybe the messaging service is not on, or something similar.
Maybe some more experience mobility developers can help you more with that.

Lili Tagetes
30th September 2011, 16:50
thanks for advice :)