Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 1,635
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Read Inbound & Outbound SMS Messages on BB10 devices

mwoolley wrote:

No, Message objects may have Attachment objects. For example, here's my code which shows this:


void SmsMessageService::messageReceived(bb::pim::account::AccountKey account_key, bb::pim::message::ConversationKey conv, bb::pim::message::MessageKey message_key) {

	qDebug() << "XXXX messageReceived";

	Message message = _message_service->message(_sms_account_id, message_key);

	qDebug() << "XXXX Message mime type:" << message.mimeType();
	if (message.mimeType() == MimeTypes::Sms) {
		qDebug() << "XXXX messageReceived: It's an SMS!!!";
		if (message.isInbound()) {
			qDebug() << "XXXX sender:" << message.sender().displayableName();
			if (message.attachmentCount() > 0) {
				showToast("SMS received");
				bb::pim::message::Attachment attachment = message.attachmentAt(0);
				log(QString("RCVD: SMS\n").append("RCVD: from " + message.sender().displayableName()).append("\nRCVD: ").append(QString(attachment.data())));
			} else {
				qDebug() << "XXXX messageReceived: no attachments";
		} else {
			qDebug() << "XXXX messageReceived: not inbound";
	}  else {
		qDebug() << "XXXX messageReceived: not an SMS";


Thanks.  So I don't need to use messagesAdded() signal then? 


If your above code what happens if the message does not have an attachment? do you fall back to getting the message body?



Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Yes, you need to continue to use messageAdded. I just called my *slot* messageReceived.


If the message is an SMS it will have an Attachment.

Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Regular Contributor
Posts: 205
Registered: ‎06-11-2013
My Device: Blackbery z10
My Carrier: RIM

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Thank you