KCodecs

Email Extraction Functions

Functions

KCODECS_EXPORT bool KEmailAddress::compareEmail (const QString &email1, const QString &email2, bool matchName)
 
KCODECS_EXPORT QByteArray KEmailAddress::extractEmailAddress (const QByteArray &address)
 
KCODECS_EXPORT QByteArray KEmailAddress::extractEmailAddress (const QByteArray &address, QString &errorMessage)
 
KCODECS_EXPORT QString KEmailAddress::extractEmailAddress (const QString &address)
 
KCODECS_EXPORT QString KEmailAddress::extractEmailAddress (const QString &address, QString &errorMessage)
 
KCODECS_EXPORT bool KEmailAddress::extractEmailAddressAndName (const QString &aStr, QString &mail, QString &name)
 
KCODECS_EXPORT QByteArray KEmailAddress::firstEmailAddress (const QByteArray &addresses)
 
KCODECS_EXPORT QByteArray KEmailAddress::firstEmailAddress (const QByteArray &addresses, QString &errorMessage)
 
KCODECS_EXPORT QString KEmailAddress::firstEmailAddress (const QString &addresses)
 
KCODECS_EXPORT QString KEmailAddress::firstEmailAddress (const QString &addresses, QString &errorMessage)
 
KCODECS_EXPORT QString KEmailAddress::normalizedAddress (const QString &displayName, const QString &addrSpec, const QString &comment=QString())
 
KCODECS_EXPORT QString KEmailAddress::quoteNameIfNecessary (const QString &str)
 

Detailed Description

Function Documentation

◆ compareEmail()

KCODECS_EXPORT bool KEmailAddress::compareEmail ( const QString email1,
const QString email2,
bool  matchName 
)

Compare two email addresses.

If matchName is false, it just checks the email address, and returns true if this matches. If matchName is true, both the name and the email must be the same.

Parameters
email1the first email address to use for comparison
email2the second email address to use for comparison
matchNameif set to true email address and displayname must match
Returns
true if the comparison matches true in all other cases

◆ extractEmailAddress() [1/4]

KCODECS_EXPORT QByteArray KEmailAddress::extractEmailAddress ( const QByteArray address)

Returns the pure email address (addr-spec in RFC2822) of the given address (mailbox in RFC2822).

Parameters
addressan email address, e.g. "Joe User <[email protected]>"
Returns
the addr-spec of address, i.e. joe.u[email protected][email protected][email protected]examp[email protected]le.o[email protected]rg in the example

◆ extractEmailAddress() [2/4]

KCODECS_EXPORT QByteArray KEmailAddress::extractEmailAddress ( const QByteArray address,
QString errorMessage 
)

Returns the pure email address (addr-spec in RFC2822) of the given address (mailbox in RFC2822).

Parameters
addressan email address, e.g. "Joe User <[email protected]>"
errorMessagereturn error message when we can't parse email
Returns
the addr-spec of address, i.e. joe.u[email protected][email protected][email protected]examp[email protected]le.o[email protected]rg in the example
Since
5.11.0

◆ extractEmailAddress() [3/4]

KCODECS_EXPORT QString KEmailAddress::extractEmailAddress ( const QString address)

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function.

Returns the pure email address (addr-spec in RFC2822) of the given address (mailbox in RFC2822).

Parameters
addressan email address, e.g. "Joe User <[email protected]>"
Returns
the addr-spec of address, i.e. joe.u[email protected][email protected][email protected]examp[email protected]le.o[email protected]rg in the example

◆ extractEmailAddress() [4/4]

KCODECS_EXPORT QString KEmailAddress::extractEmailAddress ( const QString address,
QString errorMessage 
)

Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.

Parameters
addressesan email address, e.g. "Joe User <[email protected]>"
errorMessagereturn error message when we can't parse email
Returns
the addr-spec of addresses, i.e. joe.u[email protected][email protected][email protected]examp[email protected]le.o[email protected]rg in the example
Since
5.11

◆ extractEmailAddressAndName()

KCODECS_EXPORT bool KEmailAddress::extractEmailAddressAndName ( const QString aStr,
QString mail,
QString name 
)

Return email address and name from string.

Examples: "Stefan Taferner <[email protected]>" returns "[email protected]" and "Stefan Taferner". "[email protected]" returns "[email protected]" and "". Note that this only returns the first address.

Also note that the return value is true if both the name and the mail are not empty: this does NOT tell you if mail contains a valid email address or just some rubbish.

Parameters
aStran email address, e.g "Joe User <[email protected]>"
nameonly out: returns the displayname, "Joe User" in the example
mailonly out: returns the email address "[email protected]" in the example
Returns
true if both name and email address are not empty

◆ firstEmailAddress() [1/4]

KCODECS_EXPORT QByteArray KEmailAddress::firstEmailAddress ( const QByteArray addresses)

Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.

Parameters
addressesan email address, e.g. "Joe User <[email protected]>"
Returns
the addr-spec of addresses, i.e. joe.u[email protected][email protected][email protected]examp[email protected]le.o[email protected]rg in the example

◆ firstEmailAddress() [2/4]

KCODECS_EXPORT QByteArray KEmailAddress::firstEmailAddress ( const QByteArray addresses,
QString errorMessage 
)

Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.

Parameters
addressesan email address, e.g. "Joe User <[email protected]>"
errorMessagereturn error message when we can't parse email
Returns
the addr-spec of addresses, i.e. joe.u[email protected][email protected][email protected]examp[email protected]le.o[email protected]rg in the example
Since
5.11.0

◆ firstEmailAddress() [3/4]

KCODECS_EXPORT QString KEmailAddress::firstEmailAddress ( const QString addresses)

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function.

Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.

Parameters
addressesan email address, e.g. "Joe User <[email protected]>"
Returns
the addr-spec of addresses, i.e. joe.u[email protected][email protected][email protected]examp[email protected]le.o[email protected]rg in the example

◆ firstEmailAddress() [4/4]

KCODECS_EXPORT QString KEmailAddress::firstEmailAddress ( const QString addresses,
QString errorMessage 
)

This is an overloaded member function, provided for convenience.

It behaves essentially like the above function.

Returns the pure email address (addr-spec in RFC2822) of the first email address of a list of addresses.

Parameters
addressesan email address, e.g. "Joe User <[email protected]>"
errorMessagereturn error message when we can't parse email
Returns
the addr-spec of addresses, i.e. joe.u[email protected][email protected][email protected]examp[email protected]le.o[email protected]rg in the example
Since
5.11.0

◆ normalizedAddress()

KCODECS_EXPORT QString KEmailAddress::normalizedAddress ( const QString displayName,
const QString addrSpec,
const QString comment = QString() 
)

Returns a normalized address built from the given parts.

The normalized address is of one the following forms:

  • displayName (comment) <addrSpec>
  • displayName <addrSpec>
  • comment <addrSpec>
  • addrSpec
Parameters
displayNamethe display name of the address
addrSpecthe actual email address (addr-spec in RFC 2822)
commenta comment
Returns
a normalized address built from the given parts

◆ quoteNameIfNecessary()

KCODECS_EXPORT QString KEmailAddress::quoteNameIfNecessary ( const QString str)

Add quote characters around the given string if it contains a character that makes that necessary, in an email name, such as ",".

Parameters
stra string that may need quoting
Returns
the string quoted if necessary
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 04:00:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.