encode attachment up front so that unicode xml does not fail