1

是否可以使用级联 API 以编程方式在 Blackberry10 上导入/导出短信/彩信?

4

1 回答 1

2

SMS 实际上使用与其他消息(如电子邮件)相同的 API。关键区别在于您要专门选择 SMS 帐户,并且您可能希望将其构建为对话的一部分。

使用 BlackBerry PIM API 的Message部分,尝试如下操作:

            MessageService messageService;
            AccountService accountService;
            //Get the SMS/MMS account
            QList<Account> accountList = accountService.accounts(Service::Messages,"sms-mms");
            AccountKey accountId =  accountList.first().id();
            // Create a contact to whom you want to send sms/mms. Put the right phone number in yourself
            int contactKey   = -1;
            MessageContact recipient = MessageContact(contactKey, MessageContact::To,"5555555555", "5555555555");

            //Create a conversation  because sms/mms chats most of the time is a conversation
            ConversationBuilder* conversationBuilder = ConversationBuilder::create();
            conversationBuilder->accountId(accountId);
            QList<MessageContact> participants;

            participants.append(recipient);

            conversationBuilder->participants(participants);

            Conversation conversation = *conversationBuilder;
            ConversationKey conversationId = messageService.save(accountId, conversation);

           //Create a message Builder for sms/mms
            MessageBuilder* messageBuilder = MessageBuilder::create(accountId);
            messageBuilder->addRecipient(recipient);
            // SMS API's handle body as an attachment.
            QString body = "body of the sms";
            messageBuilder->addAttachment(Attachment("text/plain","body.txt",body));
            messageBuilder->conversationId(conversationId);
            Message message;
            message = *messageBuilder;

            //Sending SMS/MMS
            MessageKey key = messageService.send(accountId, message);
            qDebug() << "+++++++ Message sent" << endl;`
于 2013-02-27T20:29:30.237 回答