diff --git a/src/emailAddress.cpp b/src/emailAddress.cpp index 09d08780..7136a5b4 100644 --- a/src/emailAddress.cpp +++ b/src/emailAddress.cpp @@ -26,6 +26,7 @@ #include "vmime/platform.hpp" #include "vmime/parserHelpers.hpp" +#include "vmime/utility/outputStreamAdapter.hpp" #include "vmime/utility/outputStreamStringAdapter.hpp" #include "vmime/utility/stringUtils.hpp" @@ -510,4 +511,18 @@ bool emailAddress::isEmpty() const } +const string emailAddress::toString() const +{ + std::ostringstream oss; + utility::outputStreamAdapter adapter(oss); + + generationContext ctx(generationContext::getDefaultContext()); + ctx.setMaxLineLength(lineLengthLimits::infinite); + + generateImpl(ctx, adapter, 0, NULL); + + return oss.str(); +} + + } // vmime diff --git a/vmime/emailAddress.hpp b/vmime/emailAddress.hpp index 598d0f45..458e6753 100644 --- a/vmime/emailAddress.hpp +++ b/vmime/emailAddress.hpp @@ -78,6 +78,13 @@ public: */ bool isEmpty() const; + /** Returns the email address as a string, by joining components. + * (ie. the local name, followed by a @ then the domain name.) + * + * @return email address as a string + */ + const string toString() const; + // Comparison bool operator==(const class emailAddress& eml) const; bool operator!=(const class emailAddress& eml) const;