Problems sending SMS using SMSTransport

I am trying to send an SMS using SMSTransport, but I get the following result when my application tries to send a message:

TMTP::setupFdListener
TMTP::handleConnected - Connected to ChatService
New Session Request
Open Success:
Session Details "https://discoveryservice.blackberry.com/discoveryPoxmlServlet/" "1.0" "127.0.0.1" 8888
creation of local SMS-MMS account succeeded
Created instance of PIMCoreStatusManager
PIMCoreStatusManager Constructor
Calling AccountServicePrivate::defaultAccount for service type= "messages"
Setting Curl Global Init 0
GET 0x1
URL Buffer: http://127.0.0.1:8888/accounts/default/messages 

Curl Easy perform
Curl Easy GetInfo response code
Curl easy getInfo content_length_download
Curl Error Code 0
Response Code 200
Get Contacts: (QVariant(int, 4) ) 

PIMCoreAccessPool::getPca 0 Thread Id 0x1
PIMCoreAccessPool::getPca a new PimAccess 0
getContactDtails called 4
GET 0x1
URL Buffer: http://127.0.0.1:8888/contact/4/4 

Curl Easy perform
Curl Easy GetInfo response code
Curl easy getInfo content_length_download
Curl Error Code 0
Response Code 200
TMTP::send origPort 0 destPort 0
TMTP::send attachments 0
TMTP::send invalid attachment

Here is the code I use to send the message:

void AlertUtilities::sendSMSMessage(QString subject, QString body)
{
    SmsTransport smsTransport;
    AccountService accountService;
    ContactService contactService;
    Account account = accountService.defaultAccount(Service::Messages);
    MessageBuilder* messageBuilder = MessageBuilder::create(account.id());

    QList contactIds = settings->getSelectedContacts();

    for (int i = 0; i < contactIds.length(); i++)
    {
        Contact contact = contactService.contactDetails(
                contactIds.at(i).toInt());

        if (contact.phoneNumbers().length() > 0)
        {
            MessageContact messageContact = MessageContact(i + 1,
                    MessageContact::To, contact.displayName(),
                    contact.phoneNumbers().at(0).value());
            messageBuilder->addRecipient(messageContact);
        }
    }

    Message newMessage = messageBuilder->body(MessageBody::PlainText,
            QByteArray("This is a test"));

        smsTransport.send(0, newMessage);
}

Can someone help me understand what I'm doing wrong here?  There seems to be no documentation or examples on how to do it properly.

Looks like I've got a code snippet rather autonomous and complete handy for this one as well.  (I think you can find others scattered around these forums as well.)  Here it is:

void sendSms(const QString &messageText, const QStringList &phoneNumbers) {
    bb::pim::account::AccountService accountService;
    QList accountList =
        accountService.accounts(bb::pim::account::Service::Messages, "sms-mms");

    bb::pim::account::AccountKey smsAccountId = 0;
    if(!accountList.isEmpty()) {
        smsAccountId = accountList.first().id();
        qDebug() << "SMS-MMS account ID:" << smsAccountId;
    }
    else {
        qWarning() << "Could not find SMS account";
        return;
    }

    bb::pim::message::MessageService messageService;

    QList participants;
    foreach(const QString &phoneNumber, phoneNumbers) {
        bb::pim::message::MessageContact recipient = bb::pim::message::MessageContact(
            -1, bb::pim::message::MessageContact::To,
            phoneNumber, phoneNumber);
        participants.append(recipient);
    }

    bb::pim::message::ConversationBuilder *conversationBuilder =
        bb::pim::message::ConversationBuilder::create();
    conversationBuilder->accountId(smsAccountId);
    conversationBuilder->participants(participants);

    bb::pim::message::Conversation conversation = *conversationBuilder;
    bb::pim::message::ConversationKey conversationId = messageService.save(smsAccountId, conversation);

    bb::pim::message::MessageBuilder *builder =
        bb::pim::message::MessageBuilder::create(smsAccountId);
    builder->conversationId(conversationId);

    builder->addAttachment(bb::pim::message::Attachment("text/plain", "", messageText.toUtf8()));

    foreach(const bb::pim::message::MessageContact recipient, participants) {
        builder->addRecipient(recipient);
    }

    bb::pim::message::Message message = *builder;

    messageService.send(smsAccountId, message);

    delete builder;
    delete conversationBuilder;

Tags: BlackBerry Developers

Similar Questions

  • Sending sms using labview

    Hello!!

    It comes to my school project. I need to implement the design to send sms using labview. And I use iTegno 3000 modem and I have no idea where to start. Can someone has a basic idea for me? All the specific commands to use for the modem I use?

    Thank you very much for your help

    Good day! looking forward to all your kind reply...

    Your sequence of structures aren't absolutely necessary and are just getting in the way so delete.

    You do not have a phone number - the yyyyyy is not all correct and you do not send a CTRL-z character. You send the text "ctrl + z". Set the string to display hexadecimal constant and enter 1.

  • want to send sms using java

    I'm developing a stand-alone Java application that contains sms sending to certain numbers.

    I want to send sms using java and my phone connected to my pc with a usb cable (and not via Bluetooth).

    I use Linux operating system (Arch linux).

    I tried a few libraries that uses the sms online portals, but for some reason, I don't want to pay these sites. (just to make my card SIM cause its economic want).

    Help appreciated

    880667 wrote:
    I'm developing a stand-alone Java application that contains sms sending to certain numbers.

    I want to send sms using java and my phone connected to my pc with a usb cable (and not via Bluetooth).

    I use Linux operating system (Arch linux).

    I tried a few libraries that uses the sms online portals, but for some reason, I don't want to pay these sites. (just to make my card SIM cause its economic want).

    Help appreciatede

    The first thing you need to check: are you able to access other services my connection your phone by USB to the computer (line GPRS, calling). Because it requires the call or SMS access to the port. And you said that it is economic by sending an SMS using mobile, that depends. But most of the time, it is best to use the SMS service provider getway. They provide details http or FTP, there just put or message in the form accepitng, things happen by providing it service.

  • Send SMS using Oracle database automatically

    Hi all:

    I want to send SMS from Oracle 9i automatically database. What reg software. can I use?

    Hello

    Here's the Oracle Forms forum.
    You would have more chance of getting the answers by posting in the forum database ; D

    François

  • Problem sending SMS to a GROUP

    Hi all

    I recently created a group to send bulk sms to people.

    When I select a group and send the message, it sends it to each of them.

    When a group is selected, it displays a number beside him...

    As... I have a selected group family, whenever I select that group sms, it shows me "family (4/7)" in the receipants view, and when I send the message it send only 4 of the 7 of them and not all the...

    I tried to remove and add the group... but it did not help.

    Please, if anyone can help me with this.

    Thanks in advance.


  • sending sms using java

    Hi all! I do a web application project in j2ee because I need to put the sms Setup by using the java program and I have no idea about it so I kindly ask you help me on this...
    Thank you
    Vinoth...

    a friend this is not the forum for this :)... newways you need a way to portal sms for texting... do you have material hv supported

  • Sending SMS: is it possible to add an entry from sent SMS/trash

    Hi all

    I am able to send SMS using MessageConnection/DatagramConnection, but is it possible to add them to the sent SMS/trash on device?

    According to the api folder of my knowledge only with e-mail Messages.

    Thanks in advance.

    There is no API to access the sms folders

  • BlackBerry Z10 problem receiving and sending SMS

    I'll have a problem, send and receive SMS messages. My carrier is Verizon. Maybe 1 out of 20 messages will make. When people called me and told me that they never got my messages, I tried to send me a few messages to check and none of them have been through. Does anyone know what would cause this and how to fix it? Thank you, Chris.

    Found the problem. For anyone who feels the same:

    Reach:

    -Area phone call

    -settings

    -Smart dial

    -country code: + 1

    -Guide: your area code

    -Link Nation No.: 10

    -L' use 1 for nothing (off)

    -Click on the reset bottom button

  • Problem with sending SMS programmatically to multiple recipients:

    Hello world

    I try to send information by SMS to multiple recipients at the same time programmatically. When I am trying to send SMS messages to a recipient, it works fine. I am able to send the data to a recipient successfully without any problems. But when I try to send to multiple recipients (more than one) in the code below loop 'for', it does not send to all recipients. That is to say, sometimes he sent the data to the only recipient if there are two numbers of beneficiaries (or) sometimes is not even send SMS to anyone (or the) sometimes sent to all recipients. Like that it is not consistent way when trying to send to multiple recipients at the same time.

    I even tried to use 'invokeAndWait' before calling the SMSThread code, but still the same problems.

    Could someone guide how I can resolve to send content to multiple users at the same time?

    public void SendMultipleSMS()
        {
            // multiple recipients stored here
            _data = (Vector) store.getContents();
            long totalSize = _data.size(); // totalSize - recipients count
            boolean yesLastSMS = false;
    
            // totalSize - recipients count
            if ( totalSize>0 )
            {
                _payload = null;
                _payload = contactsDetToSend(); // Content to send
    
                for ( int i=0; i			 

    I fixed it by moving beneficiaries 'for' code for the loop inside the SMSThread itself and sending to multile numbers at a time.

  • Using Firefox 4 and Windows 7. Whenever I have to start Firefox from a shortcut to a Web site, what happens with the following error "there was a problem sending the command to the program". The requested site is loaded after that. without any problem.

    Using Firefox 4 and Windows 7. Whenever I have to start Firefox from a shortcut to a Web site, what happens with the following error "there was a problem sending the command to the program". The requested site is loaded after that. without any problem.

    If a shortcut is used while Firefox is already open the error will not occur.

    For me, the problem was the FoxClock extension. Once I disabled it, the problem was gone.

    Hope this helps.

    Olivier

  • Using Autodesk Architecture 3.3 and opening a working file, I get the error message error "there was a problem sending the command to the program".

    When using Autodesk Architecture 3.3 and opening a working file, I get the error error message "there was a problem sending the command to the program". What does that mean? At the same time (or nearly the same time) trying to create a pdf from a drawing file is suspended the program autodesk. These two worked before.

    Hello

    The question you posted would be better suited to the Forums from Autodesk. I suggest you post here for better support.

    Here is a link:

    http://forums.Autodesk.com/

  • Send and receive SMS using JDE and WMA JSR120

    Hello
    I've written a midlet that send and receive TEXT messages.
    This midlet works well using Sun WTK, I can send SMS of midlet and receive...

    How can I send and receive SMS using BB JDE?

    Help, please
    Thank you!

    Take a look at this thread:

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=15778&query.ID=19...

  • Contact retrieve and send sms problem

    Note: i have change some funtion

    Hi all

    I started a thread of smsListening incoming when private number send sms I called the contact of recovery funtion.i am not able to send sms.

      private  class ListeningThread extends Thread   {       public void run()      {
    
              try {
    
                   iContact=new ContactUtility();                (iContact).Retieveallcontact(address);            } catch (PIMException e) {                // TODO Auto-generated catch block                e.printStackTrace();          }
    
            }
    

    It is in a way I am recovery contact and send sms method...

    void Retieveallcontact(String address) throws PIMException    {    Enumeration e=contactList.items();       _sender = new SendThread();       _sender.openmessage(address);         _sender.start();              while(e.hasMoreElements())        {             _sender.send(innerStream.toString());                       }                 _sender.stop();    
    
        }     private class SendThread extends Thread    {        private volatile boolean _start = false;        String msg;        private volatile boolean _stop=false;        String Address;        String address = "sms://";                               MessageConnection smsconn = null;        // Requests are queued.        private synchronized void openmessage(String ddress)        {         Address=ddress;
    
                try {             smsconn = (MessageConnection)Connector.open(address);         } catch (IOException e) {             // TODO Auto-generated catch block                e.printStackTrace();          }           _stop = false;        }
    
            // Requests are queued.        private synchronized void send(String message)        {            _start = true;            msg=message;            _stop = false;        }        // Shutdown the thread.        private synchronized void stop()        {             if (smsconn != null) {                 try {                     smsconn.close();                  } catch (IOException ioe) {                       System.out.println("Closing connection caught: ");                    ioe.printStackTrace();                }             }
    
                 _stop = true;        }        public void run()        {
    
                for(;;)            {             if(_stop)             {                 return;               }                if ( _start )                {
    
                          TextMessage txtmessage =                              (TextMessage)smsconn.newMessage(MessageConnection.TEXT_MESSAGE , "//" + Address);
    
                              txtmessage.setPayloadText(msg);                           try {                             smsconn.send(txtmessage);                         } catch (InterruptedIOException e) {                              // TODO Auto-generated catch block                                e.printStackTrace();                          } catch (IOException e) {                             // TODO Auto-generated catch block                                e.printStackTrace();                          }
    
                        _start=false;                }     
    
                }        }    }
    

    Thank you

    Hi bbdeveloper,.

    I had solved the problem with the help of invokelater.thx for your answer anyway.

    THX,

    Ketan

  • I'm having problems trying to use the

    IM Tony, I have an iPhone 6 more and since the update, I tried to use the animated messages but seems that theres also problem with the power button. The arrow leaves no other icons appear.

    Hi Indestruct1,

    I understand that you encounter some problems that can use the new screen effects and effects in the bubble Messages application. I have updated to iOS 10 as well and I love the new effects. I'll be happy to review some information for you.

    Use of the effects of message with iMessage on iPhone, iPad and iPod touch, this article stipulates that

    You need iMessage to send from the effects of the message. If you are unsure if you use iMessage or SMS/MMS texts, learn the difference. If you cannot send or receive effects of bubbles, make sure that you haven't reduce Motion activated.

    The same applies if you can't send or receive screen effects, check that reduce the Motion is turned off.

    Thank you for bringing your question in Apple Support communities. Have a great weekend.

  • Cannot send SMS to users no iMessage!

    This is probably my fourth post on this same issue that nobody is to give me an answer, or telling me to try something that I said did not work.

    I have an iPhone 6s with MetroPCS, for someone who is not using iMessage, the 'Add photos' icon is grayed out and it won't let me even to send an attachment. Before the last update, I was able to select the "Add attachments" button, but it is still impossible to send to the other person. I can't receive messages from group to anyone, unless they are all using iMessage, also to receive photos of users who are also no iMessage. iMessage is turned on, and I tried it works and stop. SMS is selected. I tried to take the sim card out, turning the phone, return, and reinsert the sim card and which worked for only 5 minutes, before aging again on the attachment button Add. WiFi and cellular data are both on, the two won't let me send an attachment. I reset the network settings, I did a hard reset on my phone. I did a reset based on my phone, I know that's not a problem of the carrier because it allows to work, until after I did an update in November 2015. Since then, she has been less effective. Please someone help me.

    Hi keakuki,

    I understand that you have difficulties to send SMS and MMS messages or receive group messages since you last updated your iPhone.   Your profile says you are using iOS 9.3.  You have updated to the latest version, which is iOS 9.3.1?  Once you have done this, the next step would be to see if MetroPCS has updated their software. given that the SMS and MMS messages must go through their system.

    If you can't send or receive messages on your iPhone, iPad or iPod touch

    Restart your device and check for updates

    1. Restart your device.
    2. Looking for a carrier settings update.
    3. Looking for an updated software iOS.
    1. Make sure that you are connected to the Internet through cellular data or Wi-Fi.
    2. Go to settings > Messages. Check that the type of message you are trying to send is lit (iMessage, SMS, MMS or e-mail group):

    If your messages are not sent or you do not receive the messages

    Check your details:

    1. Make sure you use the right phone number or email address of the contact.
    2. Go to settings > Messages > blocked and make sure that the contact is not on your list of blocking.

    If messages will not send to a certain person or you need assistance with group messages

    Sometimes it will not send your messages to a particular contact, or you might have problems with Group Messaging. For example, you could meet a group conversation and receive your own message. Or you could get a new phone number and see your old listed as a recipient in an existing group conversation.

    Delete the conversation * who has the problem and start a new conversation:

    1. Open your Messages and view your list of conversations.
    2. Straight shot left on the conversation you want to delete. Then, remove faucet.
    3. Open your Messages, type and enter the phone number or email address of your contact or contacts.
    4. Write a new message and press send.

    * When you delete a conversation, you will not be able to recover. If you want to save parts of conversations or their attachments, you can take screenshots. You can also tap a bubble attachment or message, and then tap more > save.

    Take care

Maybe you are looking for