Send document as e-mail

We have the file sfx2/source/dialog/mailmodel.cxx that implements the functions of class SfxMailModel_Impl

The function 
SfxMailModel_Impl::SendMailResult SfxMailModel_Impl::Send( MailDocType eMailDocType )
is responsible for selecting the appropriate mail client, attaching the document to the mail and then sending it to the destination.

In this function
It checks for any default mailclient plugin. If available launches that otherwise uses the interface

xSimpleMailClientSupplier = Reference< XSimpleMailClientSupplier >(
                    xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SimpleSystemMail" ))),
                    UNO_QUERY );
which provides access to simple mail client available.
This interface implementation is done in the file shell/source/cmdmail/cmdmailsuppl.cxx
The function responsible is 
void SAL_CALL CmdMailSuppl::sendSimpleMailMessage(const Reference<XSimpleMailMessage>& xSimpleMailMessage, sal_Int32 aFlag )

 try
    {
        // Query XNameAccess interface of the org.openoffice.Office.Common/ExternalMailer
        // configuration node to retriece the users preferred email application. This may
        // transparently by redirected to e.g. the corresponding GConf setting in GNOME.
        OUString aConfigRoot = OUString(
            RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.Common/ExternalMailer" ) );
                                                                                                                             
        PropertyValue aProperty;
        aProperty.Name = OUString::createFromAscii( "nodepath" );
        aProperty.Value = makeAny( aConfigRoot );
                                                                                                                             
        Sequence< Any > aArgumentList( 1 );
        aArgumentList[0] = makeAny( aProperty );
                                                                                                                             
        Reference< XNameAccess > xNameAccess =
            Reference< XNameAccess > (
                m_xConfigurationProvider->createInstanceWithArguments(
                    OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ),
                    aArgumentList ),
                UNO_QUERY );
                                                                                                                             
        if( !xNameAccess.is() )
        {
            OUString aMailer;
                                                                                                                             
            // Retrieve the value for "Program" node and append it feed senddoc with it
            // using the (undocumented) --mailclient switch
            xNameAccess->getByName( OUString::createFromAscii( "Program" ) ) >>= aMailer;
                                                                                                                             
            if( aMailer.getLength() )
            {
                // make sure we have a system path
                FileBase::getSystemPathFromFileURL( aMailer, aMailer );
                                                                                                                             
                aBuffer.append("--mailclient ");
                aBuffer.append(OUStringToOString( aMailer, osl_getThreadTextEncoding() ));
                aBuffer.append(" ");
            }
        }
                                                                                                                             
    }

Then the shell/source/unix/misc/senddoc.sh is responsible for chosing the appropriate program. If there is no program specified in the user configuration, generates the error

"Could not determine a mail client to use."

 
