×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    6

    [moved] Sending multiple sms

    Hello,
    First of all, i'm newbie [began to 4 days] in Symbian C++ and my english is very bad. Sorry for that :P

    I used the code http://wiki.forum.nokia.com/index.ph...Sending_an_SMS to send an sms to a constant number that i put in the code.
    It works. No problem.

    After that, i tried to use the same code to send 2 sms to a different numbers.
    I made a simple change to allow sending
    PHP Code:
        QString numbers[3];
        
    numbers[0] = "+1234567";
        
    numbers[1] = "+7654321";
        for(
    int i=0;i<2;i++)
        {
            
    RSendAs sendAs;
            
    TInt err sendAs.Connect();
            if (
    err) {
                
    // TODO: Error handling
                
    return;
            }
            
    CleanupClosePushL(sendAs);

            
    RSendAsMessage sendAsMessage;
            
    sendAsMessage.CreateL(sendAsKUidMsgTypeSMS);
            
    CleanupClosePushL(sendAsMessage);

            
    // Add the receiver
            //_LIT(KReceiver, "+123456");
            
    _LIT(KReceiver,numbers[i]);
            
    sendAsMessage.AddRecipientL(KReceiverRSendAsMessage::ESendAsRecipientTo);

            
    // Set the body text
            
    _LIT(KBodyText"hello");
            
    sendAsMessage.SetBodyTextL(KBodyText);

            
    // Send the message
            
    sendAsMessage.SendMessageAndCloseL();

            
    CleanupStack::Pop(); // sendAsMessage (already closed)
            
    CleanupStack::PopAndDestroy(); // sendAs

            //_LIT(KInfoText, "Message sent."); 
            //iAppView->LogPrintL(KInfoText);

        

    It gave me 4 errors.
    One of them is: ' Lnumbers' was not declared in this scope.
    The problem is _LIT(KReceiver,numbers[i]);
    As i understand, _LIT expects a const char*.
    Can anyone tell me how can i solve that?
    Is there a way to send message's dynamically?

    Thank u
    Vítor

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,675

    Re: Sending multiple sms

    _LIT is a macro for defining 16-bit string constants/literals. Generally it should not be used for anything else, especially since it is evaluated in compilation time. The particular issue arises from the fact that "something" is a 8-bit string, and this macro uses the ## preprocessor operator for prefixing its argument with that L (because L"something" is a string of 16-bit characters).

    http://wiki.forum.nokia.com/index.ph...S60_descriptor is for you.

    Note that you can find Qt-related boards on this site if you click back to Development Platforms above.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    Sasken Communication Technologies, Bangalore
    Posts
    22

    Re: Sending multiple sms

    If you want to send same message to multiple user, you can add multiple recipients to your message using RSendAsMessage::AddRecipientL() and no need to run for loop here.
    Code:
    sendAsMessage.AddRecipientL(KReceiver1, RSendAsMessage::ESendAsRecipientTo);
    sendAsMessage.AddRecipientL(KReceiver2, RSendAsMessage::ESendAsRecipientTo);
    .
    .

  4. #4
    Registered User
    Join Date
    Oct 2010
    Posts
    6

    Re: [moved] Sending multiple sms

    Hi, Thank you for your answers.
    wizard_hu, i saw the link u gave to me.
    After that, i tried:

    QString text = numbers[i];
    PtrC16 textPtr(reinterpret_cast<const TUint16*>(text.utf16()));
    _LIT(KReceiver,textPtr);

    Error: PtrC16 was not declared in this scope; (needs some include?)

    I tried, too:
    TBuf<60> buffer(text.utf16());
    _LIT(KReceiver,buffer);

    Error: 'Lbuffer' was not declared in this scope.

    Should i make this question in another subforum?

    Thank you so much

  5. #5
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,167

    Re: [moved] Sending multiple sms

    try TPtrC16 instead of PtrC16

  6. #6
    Registered User
    Join Date
    Oct 2010
    Posts
    6

    Re: [moved] Sending multiple sms

    TPtrC16 textPtr(reinterpret_cast<const TUint16*>(text.utf16()));
    _LIT(KReceiver,textPtr);

    Now the error is on that second line
    'LtextPtr' was not declared in this scope.
    Any ideas?

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,675

    Re: [moved] Sending multiple sms

    ... not in addition, instead ... _LIT is still used for defining constant literals in compilation time, and you are still wanting to create the recipient-descriptor in runtime.
    Forget KReceiver and pass textPtr directly to AddRecipientL.

  8. #8
    Registered User
    Join Date
    Oct 2010
    Posts
    6

    Re: [moved] Sending multiple sms

    wizard_hu_ i understand it right now!
    It works.
    Thank you so much!
    Sorry for the inconvenience, i'm in SC++ at 5 days.

Similar Threads

  1. sending sms to multiple recipients
    By 7.light in forum Mobile Java General
    Replies: 1
    Last Post: 2010-08-26, 05:54
  2. Sending SMS with multiple recipients slower then sending separate SMS
    By Zeddeh in forum [Archived] Qt Mobility Project
    Replies: 1
    Last Post: 2010-05-12, 10:46
  3. Sending SMS to multiple numbers
    By mastermindcoders in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2010-01-30, 12:37
  4. Sending SMS to multiple recipients.
    By arul_nokia in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2009-04-22, 18:19
  5. Sending SMS to Multiple Reciptents
    By anil_kumar_g in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2002-10-31, 07:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×