/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
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 ist noch experimentell.