02-01-2013 11:58 AM
I believe I have everything laid out as it should be but I cannot get my email to send
void xxx::composeMessage(QString messageTo, QString messageSubject, QString messageBody)
{
const MessageContact recipient = MessageContact(-1, MessageContact::To, QString(), "abc@xyz.com");
const QByteArray bodyData = messageBody.toUtf8();
MessageBuilder *builder = MessageBuilder::create(currentAccount.id());
qDebug() << "Current: " << messageTo << messageSubject << bodyData;
builder->subject("Test");
builder->removeAllRecipients();
builder->addRecipient(recipient);
builder->body(MessageBody::Html, bodyData);
// Send the new message via current account
qDebug() << "Message1";
messageService->send(currentAccount.id(), *builder);
qDebug() << "Message2";
}
all private variables defined in .h file.
Any ideas what I'm missing? This is the entire function, I pass the information from QML, using the qDebug() I am able to see that the function gets all the passed parameters and prints out "Message1" then the app crashes. I have also checked the .pro and bar-descriptor and believe I have all necessary includes
02-01-2013 01:28 PM
Why did you go with
MessageBuilder *builder
instead of what we have in docs:
MessageBuilder builder;
in any case try changing
messageService->send(currentAccount.id(), *builder);
to
messageService->send(currentAccount.id(), &builder);
02-01-2013 01:33 PM
02-01-2013 03:13 PM
sorry I meant
messageService->send(currentAccount.id(), builder);
02-01-2013 03:17 PM
same
error: no matching function for call to 'bb::pim::message::MessageService::send(bb::pim::account::AccountKey, bb::pim::message::MessageBuilder*&)'
02-01-2013 03:35 PM
In code from the first message try the following line:
messageService->send(currentAccount.id(), **builder);
If that won't work, try:
Message message = **builder; /// or: Message message = *builder;
messageService->send(currentAccount.id(), message);
You will need to delete the builder manually at the end of function, otherwise memory leak will occur:
delete builder;
I recommend creating the builder on stack like in example on this page so it will be destroyed automatically:
https://developer.blackberry.com/cascades/referenc
02-01-2013 03:36 PM
>I recommend creating the builder on stack like in example on this page so it will be destroyed automatically:
totally agree...
02-01-2013 03:43 PM
I originally tried that verbatim from the link you sent.
MessageBuilder builder;// = MessageBuilder::create(currentAccount.id());
qDebug() << "Current: " << messageTo << messageSubject << bodyData;
builder.subject("Test");
builder.removeAllRecipients();
builder.addRecipient(recipient);
builder.body(MessageBody::Html, bodyData);
Message message = *builder;
// Send the new message via current account
qDebug() << "Message1";
messageService->send(currentAccount.id(), message);
qDebug() << "Message2";errors:
error: no matching function for call to 'bb::pim::message::MessageBuilder::MessageBuilder()' error: no match for 'operator*' in '*builder'
02-01-2013 03:54 PM
Message message = *builder;
Yes, this looks like an error.
May be:
Message message = (Message)builder;
02-01-2013 04:15 PM