×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Error in Sending message

    hello All,
    I am working in an application that is supposed to send message via sms. I have used the following code but as soon as the class is initialized and called it throws an exception. Can anyone please have a look.


    CRSendAsSender.h
    Code:
    /*
     ============================================================================
     Name		: CRSendAsSender.h
     Author	  : Abhishek karmakar
     Version	 : 1.0
     Copyright   : Your copyright notice
     Description : CCRSendAsSender declaration
     ============================================================================
     */
    
    #ifndef CRSENDASSENDER_H
    #define CRSENDASSENDER_H
    
    #include <e32base.h>	// For CActive, link against: euser.lib
    #include <e32std.h>		// For RTimer, link against: euser.lib
    
    #include <BADESCA.H>
     
    #include <rsendasmessage.h>
    #include <rsendas.h>
    #include <MTCLREG.H>
    #include <smut.h>
    
    
    /*The Observer for the smssernder class ..this notifies when the message is sent.*/
    /*
    class MRSendSMSObserver
    	{
    	public:
    	virtual void MessageSentL(TInt aError);
    	};
    */
    
    class CCRSendAsSender : public CActive
    	{
    public:
    	~CCRSendAsSender();
    	static CCRSendAsSender* NewL(/*MRSendSMSObserver& aObserver,*/ const TDesC& aMessage,const TDesC& aRecipients );
    	
    private:
    	void RunL();
    	void DoCancel();
    	TInt RunError(TInt aError);
    public:
    	CCRSendAsSender(/*MRSendSMSObserver& aObserver*/);
    	void ConstructL(const TDesC& aMessage,const TDesC& aRecipients);
    
    private:
    	TInt iState; // State of the active object
    	RTimer iTimer; // Provides async timing service
    	//MRSendSMSObserver& 	iObserver;
    	RSendAs 			iSendAs;
    	RSendAsMessage		iSendAsMessage;
    
    	};
    
    #endif // CRSENDASSENDER_H
    CRSendAsSender.cpp
    Code:
    /*
     ============================================================================
     Name		: CRSendAsSender.cpp
     Author	  : Abhishek karmakar
     Version	 : 1.0
     Copyright   : Your copyright notice
     Description : CCRSendAsSender implementation
     ============================================================================
     */
    
    #include "CRSendAsSender.h"
    
    CCRSendAsSender::CCRSendAsSender() :
    	CActive(EPriorityStandard) // Standard priority
    	{
    	}
    CCRSendAsSender* CCRSendAsSender::NewL(const TDesC& aMessage, const TDesC& aRecipients)
    	{
    	CCRSendAsSender* self = new (ELeave) CCRSendAsSender(/*aObserver*/);
    	self->ConstructL(aMessage, aRecipients);
    	return self;
    	}
    
    void CCRSendAsSender::ConstructL(const TDesC& aMessage,	const TDesC& aRecipients)
    	{
    	CActiveScheduler::Add(this); // Add to scheduler
    
    	User::LeaveIfError(iSendAs.Connect());
    	iSendAsMessage.CreateL(iSendAs, KUidMsgTypeSMS);
    	iSendAsMessage.AddRecipientL(aRecipients,RSendAsMessage::ESendAsRecipientTo);
    	iSendAsMessage.SetBodyTextL(aMessage);
    	//iSendAsMessage.SendMessage(iStatus);
    	iSendAsMessage.SendMessageAndCloseL();
    	
    	SetActive();
    	}
    
    CCRSendAsSender::~CCRSendAsSender()
    	{
    	Cancel();
    	iSendAsMessage.Close();
    	iSendAs.Close();
    	}
    
    void CCRSendAsSender::DoCancel()
    	{
    	//iTimer.Cancel();
    	iSendAsMessage.Cancel();
    	}
    
    void CCRSendAsSender::RunL()
    	{
    	//iObserver.MessageSentL(iStatus.Int());
    	}
    TInt CCRSendAsSender::RunError(TInt aError)
    	{
    	return aError;
    	}
    i am calling this class from the Appui of my project .. like this
    Code:
    CCRSendAsSender* smssender = new (ELeave)CCRSendAsSender;
    	smssender->NewL(data,phone);
    but its showing me an 'App Closed' error after it executes completely. Any directions why is this happening ??

    many thanks
    Abhishek karmakar

    never- Never - NEVER -- !!! NEVER !!! GIVE UP

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

    Re: Error in Sending message


Similar Threads

  1. Message Sending failed !!!!!
    By ankushbabrekar in forum Symbian
    Replies: 3
    Last Post: 2007-03-23, 05:06
  2. Message Sending Failed
    By pnkdrg in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-01-15, 14:40
  3. Sending Message automatically
    By vniles in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-12-11, 11:44
  4. picture message using simple sms sending facilities
    By auvinent in forum General Messaging
    Replies: 1
    Last Post: 2002-12-31, 08:57

Posting Permissions

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