Select from a List of Available MTMs and Accounts

Steps

  1. Get a list of MTMs available on the device that could send your message by specifying the features that the MTMs must have.

    Once a filter has been set, the available MTMs can be retrieved using the RSendAs::FilteredMessageTypes against which populates a CSendAsMessageTypes object.

    /**
    Creates a SendAs message
    @param aMessage An RSendAsMessage reference, used to create a message
    */
    void CSendAs2Example::CreateL( RSendAsMessage& aMessage)
        {
            
        CSendAsMessageTypes* messageTypes = CSendAsMessageTypes::NewL();
        CleanupStack::PushL(messageTypes);  
    
        // Filter all MTMs that can send messages. 
        // This list can be refined by applying filters using FilterAgainstCapability.
        iSendAs.FilteredMessageTypesL(*messageTypes);
    
        TUid sendAsMtmUid;
            
        // Returning the message UID based on the message type 
        // such as 0 for SMTP Client, 1 for SMS Client
        // 2 for Infrared client MTM and 3 for Bluetooth client MTM.
        sendAsMtmUid = messageTypes->UidFromNameL(KSmsClient);
        
        CleanupStack::PopAndDestroy(messageTypes);  
        iConsole->Printf ( KTextCreate );
        
        TInt count = iSelection->Count();
        iEntry->SetEntryL(KMsvDraftEntryId);
        ...
        }
  2. Get a list of available accounts using RSendAs::AvailableAccountsL() hich populates a CSendAsAccounts object.

    The MTM for which to get the services is specified by the message type UID, which can be obtained from the CSendAsMessageTypes object.

    Once an account has been selected by the user, the ID of the service can be obtained to use it when creating a message.

    /**
    Displays the names of all the available accounts.
    Creates accounts, if not already created.
    */
    void CSendAs2Example::DisplayAccountL()
        {
        CSendAsAccounts* accounts = CSendAsAccounts::NewL();
        CleanupStack::PushL(accounts);
        
        // Append 3 new accounts and associated name pair.
        if(accounts->Count()==0)
            {
            accounts->AppendAccountL(KAccount1, 0xaaaaaaaa);    
            }
        
        if(accounts->Count()==1)
            {
            accounts->AppendAccountL(KAccount2, 0x55555555);    
            }
            
        if(accounts->Count()==2)
            {
            accounts->AppendAccountL(KAccount3, 0x22222222);    
            }
        iConsole->Printf( KAccountNames );
        iConsole->Printf ( KPressAnyKey );
        iConsole->Getch ();
        
        // Display the array of names of accounts for this message type
        for(TInt I = 0; I < 3; I++)
            {
            TPtrC array = accounts->AccountNames().MdcaPoint(I);
            iConsole->Printf( array ); 
            }
            
        CleanupStack::PopAndDestroy(accounts);
        
        }

Results

Result of carrying out the task