I'm pulling email addresses from an oracle DB. Every now and then I get the following error:
javax.mail.internet.AddressException: Illegal address in string ``''
at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:108)
The email addresses look normal. Usually something like xxxx@yahoo.com ... It's only occurring with some users that have provided more than one email address. When we pull multiple addresses for a certain user, we use the following code to process the data:
protected InternetAddress[] getEmailAddresses(String emails) throws Exception {
String[] emailArray = emails.split(" ");
ArrayList temp = new ArrayList();
for (int i=0; i < emailArray.length; i++) {
temp.add(new InternetAddress(emailArray));
}
return (InternetAddress[])temp.toArray(new InternetAddress[] {});
}
Pretty much, I just send it a string containing all of the email addresses for each user. Could there be an issue with emails.split(" ") ?
The email addresses are added to a string by doing the following:
while (emailData.next()) {
emailAddress = emailAddress + " " + emailData.getString(1);
}
emailData contains the database object, the oracle ResultSet.
Any ideas?
Edited by: jreyno24 on Feb 12, 2008 7:09 AM