Wednesday, February 21, 2007

RSendAs : Send a file bluetooth

A number of people seem to have a problem using RSendAs to send a file via Bluetooth but its more or less the same as sending any other message.

To start, you need to get hold of the bluetooth MTM UID, its in "SendUiConsts.h"

Then its simply a case of:

1. Opening the SendAs session
2. Creating a message using the session
3. Adding the file as an attachment
4. Sending the message

void SendFileL(const TDesC& aFilename)
{
// 1. Open session
RSendAs session;
User::LeaveIfError(session.Connect());
CleanupClosePushL(session);

// 2. Create message
RSendAsMessage message;
message.CreateL(session, KSenduiMtmBtUid);
CleanupClosePushL(message);

// 3. Add attachment
TRequestStatus status;
message.AddAttachment(aFilename.FullName(), status);
User::WaitForRequest(status);

// 4. Send message
if (status.Int() == KErrNone)
{
CleanupStack::Pop(&message);
message.LaunchEditorAndCloseL();
}
else
CleanupStack::PopAndDestroy(&message);

CleanupStack::PopAndDestroy(&session);
}

1 comment:

raghukiran said...

Hi,
I tried this code on S60 FP2 and the application leaves after creating the message. Any idea why this is happening?

Thanks,
Raghu

stats counter