Create a Sssion with the SendAs Server

Steps

  1. Create a session with the SendAs Server using the RSendAs::Connect() function.

  2. Connect to the server using the default number of message slots available to a session, which is 4, (KSendAsDefaultMessageSlots).

  3. Set the message entry using the CMsvEntry::SetEntryL() function.

  4. Get the IDs of all the context children, using the CMsvEntry::ChildrenL() function.

  5. Empty the draft folder before creating a new message using the CleanMessageFolderL() function.

Example

// SendAs2Example.h
...
class CSendAs2Example : public CBase
{
public:
    static CSendAs2Example* NewL();
    ~CSendAs2Example();
    void StartL();
    void Connect();
    void CreateL(RSendAsMessage& aMessage);
    void DisplayAccountL();
    void CapabilityFilterL();
    void SendL(RSendAsMessage& aMessage);
    
private:
    CSendAs2Example();
    void ConstructL();
    void CleanMessageFolderL();

private:
    /** Pointer to the console interface */
    CConsoleBase*          iConsole;
    RSendAs                iSendAs;
    /** Pointer to Session observer used to report whatever notification it receives */ 
    CDummyObserver*        iObserver;
    /** Pointer to the channel of communication between a client thread and the Message Server */
    CMsvSession*           iSession;
    /** Pointer to a particular Message Server entry */
    CMsvEntry*                 iEntry;
    /** Pointer to the array of entry IDs */
    CMsvEntrySelection*    iSelection;
};
// SendAs2Example.cpp
...

/**
Allocates and constructs a CSendAs2Example object.
Initialises all member data to their default values.
*/  
CSendAs2Example* CSendAs2Example::NewL()
    {
    CSendAs2Example* self = new (ELeave) CSendAs2Example();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop();
    return self;
    }
    
/**
Constructor
*/  
CSendAs2Example::CSendAs2Example()
    {   
        
    }
...

/**
Creates a session
    - based on the time slots
    - connects to the server
    @leave system wide error codes
*/

void CSendAs2Example::Connect()
    {
    iConsole->Printf ( KTextConn );
    TInt err = iSendAs.Connect(KSendAsDefaultMessageSlots);
    if ( err == KErrNone)
        {
        iConsole->Printf ( KTextErrInn );
        }
    else
        {
        iConsole->Printf ( KTextErrOut );
        }
    }