using com::sun::star::beans::PropertyValue; using com::sun::star::system::XSimpleMailClientSupplier; using com::sun::star::system::XSimpleMailClient; using com::sun::star::system::XSimpleMailMessage; using com::sun::star::system::XSimpleMailMessage2; using com::sun::star::container::XNameAccess; using osl::FileBase;
try
{ // Query XNameAccess interface of the org.openoffice.Office.Common/ExternalMailer // configuration node to retrieve the users preferred email application. This may // transparently by redirected to e.g. the corresponding GConf setting in GNOME.
// Retrieve the value for "Program" node and append it feed senddoc with it // using the (undocumented) --mailclient switch
xNameAccess->getByName(u"Program"_ustr) >>= aMailer;
if( !aMailer.isEmpty() )
{ // make sure we have a system path
FileBase::getSystemPathFromFileURL( aMailer, aMailer );
// Convert from, to, etc. in a best-effort rather than a strict way to the // system encoding, based on the assumption that the relevant address parts // of those strings are ASCII anyway and any problematic characters are only // in the human-readable, informational-only parts:
// Append originator if set in the message if ( !xSimpleMailMessage->getOriginator().isEmpty() )
{
aBuffer.append(" --from ");
appendShellWord(aBuffer, xSimpleMailMessage->getOriginator(), false);
}
// Append recipient if set in the message if ( !xSimpleMailMessage->getRecipient().isEmpty() )
{
aBuffer.append(" --to ");
appendShellWord(aBuffer, xSimpleMailMessage->getRecipient(), false);
}
// Append carbon copy recipients set in the message
Sequence< OUString > aStringList = xSimpleMailMessage->getCcRecipient(); for (constauto& rString : aStringList)
{
aBuffer.append(" --cc ");
appendShellWord(aBuffer, rString, false);
}
// Append blind carbon copy recipients set in the message
aStringList = xSimpleMailMessage->getBccRecipient(); for (constauto& rString : aStringList)
{
aBuffer.append(" --bcc ");
appendShellWord(aBuffer, rString, false);
}
// Append subject if set in the message if ( !xSimpleMailMessage->getSubject().isEmpty() )
{
aBuffer.append(" --subject ");
appendShellWord(aBuffer, xSimpleMailMessage->getSubject(), false);
}
// Append attachments set in the message
aStringList = xSimpleMailMessage->getAttachement(); for (constauto& rString : aStringList)
{
OUString aSystemPath; if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(rString, aSystemPath) )
{
aBuffer.append(" --attach ");
appendShellWord(aBuffer, aSystemPath, true);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.