×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Super Contributor
    Join Date
    Mar 2003
    Posts
    2,426

    Error using CSendAs::CreateMessageL

    I'm trying to use the CSendAs class. It seems straight-forward but I'm running into problems.
    Does anyone know what I'm doing wrong?

    CSendAsObserver observer;
    CSendAs* iSendAs = CSendAs::NewL(observer);
    CleanupStack::PushL(iSendAs);

    iSendAs->SetMtmL(KUidMsgTypeSMTP);

    if (iSendAs->AvailableServices().Count() >= 1)
    iSendAs->SetService(0);

    /*This next line fails in E32User - CBase with reason code of 21.

    As an aside, the trap is not trapping. Why would that be?
    */
    TRAPD(r, iSendAs->CreateMessageL());

    Thanks for your help.

    Posted by Kate Glickman, kate_glickman@us.ibm.com
    on April 19, 2002 at 22:23

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Posts
    2,426

    RE: Error using CSendAs::CreateMessageL

    Posted by Forum_Nokia Developer_Support, communicator.developer@nokia.com
    on April 22, 2002 at 13:17

    Hi,

    Firstly you shouldn't have a C (CSendAsObserver) type class on the stack (the stack is quite small on SymbianOS). It's better to either create one using new or just derive from MSendAsObserver and use *this when creating the NewL.

    Note that member vairable by convention start with the letter 'i' in SymbianOS code and don't have to be pushed onto the cleanup stack. So, the declared iSendAs should either be a member variable and not on the stack or called sendAs and put on the stack (and taken off again).

    Also, the TRAP macro can only trap 'Leaves' and not panics, which is what you are getting.

    Here is a modified version of the code, which creates a message, adds a recipient and some text and finally saves the message in the drafts box:
    CParaFormatLayer*paraFormat=CParaFormatLayer::NewL();
    CleanupStack::PushL(paraFormat);

    CCharFormatLayer*charFormat=CCharFormatLayer::NewL();
    CleanupStack::PushL(charFormat);

    CSendAs* sendAs = CSendAs::NewL(*this);
    CleanupStack::PushL(sendAs);

    sendAs->SetMtmL(KUidMsgTypeSMTP);

    if (sendAs->AvailableServices().Count() >= 1)
    sendAs->SetService(0);

    sendAs->CreateMessageL();
    sendAs->AddRecipientL(_L("recipient@message.com"));

    CRichText* body=CRichText::NewL(paraFormat,charFormat);
    CleanupStack::PushL(body);

    TBuf<100> msg = _L("Hello, World");
    body->InsertL(0,msg);
    sendAs->SetBodyL(*body);
    sendAs->SaveMessageL();

    CleanupStack::PopAndDestroy(body);
    CleanupStack::PopAndDestroy(sendAs);
    CleanupStack::PopAndDestroy(charFormat);
    CleanupStack::PopAndDestroy(paraFormat);

    FN Developer Support

Posting Permissions

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