Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: sendas.h
Link against: send.lib

Class CSendAs

CSendAs

Support

Supported from 5.0

Description

Encapsulates the Send-As functionality provided by the Messaging Architecture.

It allows applications simply to package data into outgoing messages without using directly the MTM interfaces.

The class is failure-safe in that if it gets deleted before the client application commits the message, the message is abandoned rather than saved in a potentially indeterminate state, which could later cause problems in the Message Server.

If the MTM requires the data to be rendered (i.e. printed), then, when saving the message, the CSendAs class calls back to the application using the mixin observer, and give the UID of the printer driver to use and the filename the printer should produce.

Derivation

CActiveThe core class of the active object abstraction
CBaseBase class for all classes to be instantiated on the heap
CSendAsEncapsulates the Send-As functionality provided by the Messaging Architecture
MMsvSessionObserverProvides the interface for notification of events from a Message Server session

Defined in CSendAs:
AbandonMessageL(), AddMtmCapabilityL(), AddRecipientL(), AvailableMtms(), AvailableServices(), ClientMtm(), ClientRegistry(), CreateAttachmentL(), CreateMessageL(), DeleteAttachmentL(), NewL(), QueryMessageCapability(), RecipientList(), RemoveRecipient(), ResetMtmCapabilitiesL(), SaveMessageL(), SetAttachmentL(), SetBioTypeL(), SetBodyL(), SetMtmL(), SetService(), SetSubjectL(), ValidateMessage(), ~CSendAs()

Inherited from CActive:
Cancel(), Deque(), DoCancel(), EPriorityHigh, EPriorityIdle, EPriorityLow, EPriorityStandard, EPriorityUserInput, IsActive(), IsAdded(), Priority(), RunError(), RunL(), SetActive(), SetPriority(), TPriority, iStatus

Inherited from CBase:
operator new()

Inherited from MMsvSessionObserver:
EMsvCloseSession, EMsvCorruptedIndexRebuilding, EMsvCorruptedIndexRebuilt, EMsvGeneralError, EMsvMediaAvailable, EMsvMediaChanged, EMsvMediaIncorrect, EMsvMediaUnavailable, EMsvMtmGroupDeInstalled, EMsvMtmGroupInstalled, EMsvServerFailedToStart, EMsvServerReady, EMsvServerTerminated, EMsvStoreCommitted, EMsvStoreCreated, EMsvStoreDeleted, EmsvEntriesChanged, EmsvEntriesDeleted, EmsvEntriesMoved, EmsvEntryCreated, HandleSessionEvent(), HandleSessionEventL(), TMsvSessionEvent

See also:


Constructors and destructors


NewL()

static CSendAs* NewL(MSendAsObserver& aObserver);

Description

Allocates and constructs a Send-As object.

It returns a pointer to an instance of a CSendAs object. The Send-As object creates a session against the Message Server and can access the client-side MTM registry. The call returns immediately since any initialisation occurs asynchronously.

Parameters

MSendAsObserver& aObserver

An abstract interface implemented by the client. MTM capability queries may call back this interface

Return value

CSendAs*

New session object if successful


~CSendAs()

~CSendAs();

Description

Destructor.

Causes any current message to be abandoned.

[Top]


Selection of MTMs and services


AvailableMtms()

const CDesCArray& AvailableMtms() const

Description

Gets an array of MTMs that satisfy the current capability requirements.

The array could change after every call to AddRequiredCapabilityL() and ResetCapabilitiesL(). The array never contains MTMs that do not have the capability to send messages.

Return value

CDesCArray&

The array of the human-readable names of the MTMs that satisfy the current required capabilities


AddMtmCapabilityL()

void AddMtmCapabilityL(TUid aCapabilityId, TBool aResponseExpected=EFalse)

Description

Adds a capability requirement.

All MTMs that do not have this capability are removed from the current array of available MTMs, initialised by AvailableMtms(). This allows the client to filter out any unsuitable MTMs before presenting a list to the user. A client can make repeated calls to AvailableMtms() to specify different criteria.

Some clients may wish to perform additional checking of a capability response, which they can do by setting aResponseExpected to ETrue. This causes the function to call back the client’s MSendAsObserver::CapabilityOK() function, which can evaluates the capability further. For example, if the KUidMtmQueryMaxBodySize capability (maximum message body size) is specified, and aResponseExpected is ETrue, the function calls back MSendAsObserver::CapabilityOK() with the maximum message body size. That function can then check if the maximum size is large enough — returning ETrue if it is. AddMtmCapabilityL() then checks this return value: if it is not ETrue, then the MTM is removed from the available MTM array.

Parameters

TUid aCapabilityId

The UID of the required capability

TBool aResponseExpected=EFalse

Set to ETrue if the capability returns a response that needs to be checked by the client

Leave codes

 

The function calls CBaseMtm::QueryCapability() on the available MTMs. It leaves if that function does not return KErrNone or KErrNotSupported. The array of MTM names is unchanged.

See also:


ResetMtmCapabilitiesL()

void ResetMtmCapabilitiesL();

Description

Resets all capability requirements.

The MTM array then contains all the installed MTMs that can send messages.

Leave codes

KErrNoMemory

A memory allocation failed. The MTM array is unchanged


SetMtmL()

void SetMtmL(TInt aMtmIndex);

Description

Sets which MTM to use to create the message by referencing the available MTM array.

If the function leaves, then the MTM array is unchanged and a message cannot be created.

Parameters

TInt aMtmIndex

The index into the available MTM array indicating which MTM to use to create the message. The function panics if an MTM has not been set.

Leave codes

KErrNotFound

The specified MTM was not available

KErrNoMemory

A memory allocation failed


SetMtmL()

void SetMtmL(TUid aMtmUid);

Description

Sets which MTM to use to create the message by specifying a known MTM UID.

If the function leaves, then the MTM array is unchanged and a message cannot be created.

Parameters

TUid aMtmUid

The UID of the MTM to use to create the message

Leave codes

KErrNotFound

The specified MTM was not available

KErrNoMemory

A memory allocation failed

See also:


AvailableServices()

const CDesCArray& AvailableServices() const;

Description

Gets a list of the available services.

It panics if an MTM has not been set.

Return value

CDesCArray&

The list of the names of services that can be used by the chosen MTM type


SetService()

void SetService(TInt aServiceIndex);

Description

Sets the service to use for the message.

The function panics if the index is out of range or an MTM has not been set.

Parameters

TInt aServiceIndex

The index into the service list for the service to use

[Top]


Message management


CreateMessageL()

void CreateMessageL();

Description

Creates a new message.

The message is created by default in the Draft folder.

An MTM must have been set before calling this function. It panics if an MTM has not been set or a message has already been created.

If the function leaves, then the internal state of the CSendAs instance is unchanged.

Leave codes

KErrNotFound

No suitable service exists, or the MTM is not available

Other leaves

Error propagated from Message Server


CreateMessageL()

void CreateMessageL(TMsvId aId);

Description

Creates a new message, specifying the location in which to store it.

An MTM must have been set before calling this function. It panics if an MTM has not been set or a message has already been created.

If the function leaves, then the internal state of the CSendAs instance is unchanged.

Parameters

TMsvId aId

The ID of the location in which to store the message entry. See Predefined entry IDs.

Leave codes

KErrNotFound

No suitable service exists, or the MTM is not available

Other leaves

Error propagated from Message Server


AbandonMessageL()

void AbandonMessageL();

Description

Deletes a message in progress and any attachments from the Message Server.

If an MTM object has been selected, then it the selection is cancelled. It panics if the message has already been saved.

Leave codes

KErrNotFound

Message Server could not delete the message


SaveMessageL()

void SaveMessageL(TBool aMakeVisible=ETrue);
void SaveMessageL(TRequestStatus& aStatus, TBool aMakeVisible=ETrue);

Description

Commits the current message to the Message Server.

When the CSendAs object is deleted by the client application, it issues an AbandonMessage() call on itself — so to ensure that a message is sent, a client application must invoke this function before closing the Send-As API. It panics if no message has been created.

When the message requires rendering (e.g. fax), some applications might use the asynchronous version.

Parameters

TRequestStatus& aStatus

Asynchronous completion object

TBool aMakeVisible

Determines whether the message should be visible in the Outbox. Defaults to true.

Leave codes

 

The function can leave if rendering is required, and either an error occurs in requesting the MTM for the printer to use for rendering, or in MMsvSendAsObserver::RenderImage() . The message is left in the same state as it was before the call.

[Top]


Recipient management


RecipientList()

const CDesCArray& RecipientList() const;

Description

Gets a list of recipients after they have been added to the message.

It panics if no message has been created.

Return value

CDesCArray&

A text array that lists all the recipients that have been added


AddRecipientL()

void AddRecipientL(const TDesC& aRealAddress);

Description

Adds a recipient to the message.

Parameters

const TDesC& aRealAddress

The address of the recipient

Leave codes

 

Leaves can be propagated from CBaseMtm::AddAddresseeL() . The recipient is not added to the message.


AddRecipientL()

TInt AddRecipientL(const TDesC& aRealAddress, const TDesC& aAlias);

Description

Adds a recipient to the message.

Both the true address and the name or alias are specified (e.g., “an-other@somewhere.co.uk” and “A.N. Other”).

Parameters

const TDesC& aRealAddress

The address of the recipient

const TDesC& aAlias

The name or alias of the recipient rather than the actual destination

Leave codes

 

Leaves can be propagated from CBaseMtm::AddAddresseeL() . The recipient is not added to the message.


RemoveRecipient()

void RemoveRecipient(TInt aIndex);

Description

Removes a recipient from the message.

It panics if no message has been created.

Parameters

TInt aIndex

The index of the recipient array to be removed

[Top]


Contents management


SetSubjectL()

void SetSubjectL(const TDesC& aSubject);

Description

Sets the subject of the current message.

It panics if no message has been created.

Parameters

const TDesC& aSubject

Descriptor containing the subject line for the message

Leave codes

 

Leaves can be propagated from CBaseMtm::SetSubjectL() . KErrNotSupported indicates that the MTM does not support a subject field.


SetBodyL()

void SetBodyL(const CRichText& aMessageBody);

Description

Sets the body of the new message.

The outgoing message may legally be left with an empty body if the client application cannot provide the contents of its document as a CRichText object. Alternatively, the client application may wish to define a default message body, and create an attachment for the document being sent. It panics if no message has been created.

Parameters

const CRichText& aMessageBody

Message body text

Leave codes

 

Leaves can be propagated from CRichText::InsertL() .

[Top]


Message validity and capability


ValidateMessage()

TMsvPartList ValidateMessage();

Description

Checks that the message is correctly formatted for the chosen message type.

In particular, the client application is able to determine whether the recipient list is valid within the addressing syntax of the message type. Any defective part or parts are identified by the return value.

The call panics if no message has been created.

Return value

TMsvPartList

0: message is valid Non-zero: bitmask identifying defective part or parts


QueryMessageCapability()

TInt QueryMessageCapability(TUid aCapabilityId, TBool aResponseExpected=EFalse);

Description

Tests if the chosen MTM message supports a capability.

If aResponseExpected is ETrue, then the function call backs the client’s MSendAsObserver::CapabilityOK() that can evaluate the capability further.

Parameters

TUid aCapabilityId

The UID of the capability to check

TBool aResponseExpected=EFalse

ETrue if the capability returns a value that needs to be checked by the client

Return value

KErrNone

The capability is supported

KErrNotSupported

The capability is not supported

[Top]


Attachment management


CreateAttachmentL()

void CreateAttachmentL(TMsvId& aAttachmentId, TFileName& aDirectory);

Description

Creates an entry for an attachment in the Message Server index.

Once an entry has been created, the client application can save the attachment file in the directory whose name is returned. It panics if no message has been created.

Parameters

TMsvId& aAttachmentId

On return, the Message Server index ID of the attachment

TFileName& aDirectory

On return, the directory in which to save the attachment

Leave codes

 

Leaves can be propagated from CMsvEntry::CreateL() and CMsvEntry::SetEntryL() . KErrNotSupported indicates that the MTM does not support attachments. The CSendAs instance ’ s state is unchanged.

See also:


DeleteAttachmentL()

void DeleteAttachmentL(TMsvId aAttachmentId);

Description

Deletes an attachment from the message.

The attachment directory and any files in it are also deleted. It panics if no message has been created.

Parameters

TMsvId aAttachmentId

Identifies the attachment to be deleted

Leave codes

 

Leaves can be propagated from CMsvEntry::DeleteL() . The attachment is not deleted.

See also:


SetAttachmentL()

void SetAttachmentL(TMsvId aAttachmentId, const TDesC& aAttachmentName);

Support

Supported from 5.1

Description

Makes an attachment added by CreateAttachmentL() visible in the user interface of an e-mail application. By default, attachments are not be shown.

The function can be called before or after SaveMessageL(), but will be more efficient if called before.

Parameters

TMsvId aAttachmentId

The ID of the attachment, as obtained from CreateAttachmentL()

const TDesC& aAttachmentName

The name the e-mail application should give the attachment

[Top]


Advanced Messaging Architecture access


ClientRegistry()

CClientMtmRegistry& ClientRegistry();

Description

Gets direct access to Messaging’s client registry.

Return value

CClientMtmRegistry&

Client registry object


ClientMtm()

CBaseMTM& ClientMtm();

Description

Gets direct access to the class providing protocol-specific messaging functionality (a client MTM).

Return value

CBaseMTM&

Client-side MTM object


SetBioTypeL()

void SetBioTypeL(TUid aBioTypeUid);

Support

Supported from 6.0

Description

Sets the BIO type for the message.

Parameters

TUid aBioTypeUid

BIO message type