diff --git a/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailAddress.java b/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailAddress.java index e3cf573..0585dec 100644 --- a/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailAddress.java +++ b/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailAddress.java @@ -20,6 +20,9 @@ package CS2JNet.System.Net.Mail; +import javax.mail.internet.AddressException; +import javax.mail.internet.InternetAddress; + /** * @author keving * @@ -28,27 +31,27 @@ public class MailAddress { private String address, displayName, host, user; - private void parseAddress(String add) { + private void parseAddress(String add) throws AddressException { // TODO: parse address into fields - address = add; + InternetAddress parsedMailaddress = new InternetAddress(add, false); + address = parsedMailaddress.getAddress(); + displayName = parsedMailaddress.getPersonal(); } - public MailAddress(String inAddress) { + public MailAddress(String inAddress) throws AddressException { parseAddress(inAddress); } - public MailAddress(String inAddress, String inDisplayName) { + public MailAddress(String inAddress, String inDisplayName) throws AddressException { parseAddress(inAddress); if (inDisplayName != null && inDisplayName.length() > 0) - inAddress = inDisplayName; + displayName = inDisplayName; } - // TODO: - //public MailAddress(String inAddress, Encoding enc) { - // parseAddress(inAddress); - // if (inDisplayName != null && inDisplayName.length() > 0) - // inAddress = inDisplayName; - //} + public MailAddress(InternetAddress inInternetAddress) throws AddressException { + address = inInternetAddress.getAddress(); + displayName = inInternetAddress.getPersonal(); + } /** @@ -106,5 +109,6 @@ public class MailAddress { public String getAddress() { return address; } + } diff --git a/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailAddressCollection.java b/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailAddressCollection.java index 9f20700..8bf33cb 100644 --- a/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailAddressCollection.java +++ b/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailAddressCollection.java @@ -25,6 +25,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import javax.mail.internet.AddressException; + /** * @author keving * @@ -38,7 +40,7 @@ public class MailAddressCollection implements Collection { return addresses.add(arg0); } - public boolean add(String arg0) { + public boolean add(String arg0) throws AddressException { return addresses.add(new MailAddress(arg0)); } diff --git a/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailMessage.java b/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailMessage.java index 1c1db41..333b2bc 100755 --- a/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailMessage.java +++ b/CS2JLibrary/src/CS2JNet/System/Net/Mail/MailMessage.java @@ -17,7 +17,7 @@ public class MailMessage private MailAddressCollection _to; private boolean _html; private String _body; - private InternetAddress _from; + private MailAddress _from; private String _subject; public MailAddressCollection getBcc() throws Exception @@ -55,12 +55,12 @@ public class MailMessage _body = value; } - public InternetAddress getFrom() throws Exception + public MailAddress getFrom() throws Exception { return _from; } - public void setFrom(InternetAddress value) throws Exception + public void setFrom(MailAddress value) throws Exception { _from = value; } diff --git a/CS2JLibrary/src/CS2JNet/System/Web/HttpException.java b/CS2JLibrary/src/CS2JNet/System/Web/HttpException.java index e2d296f..a331dc5 100644 --- a/CS2JLibrary/src/CS2JNet/System/Web/HttpException.java +++ b/CS2JLibrary/src/CS2JNet/System/Web/HttpException.java @@ -1,4 +1,4 @@ -package RusticiSoftware.System.Web; +package CS2JNet.System.Web; public class HttpException extends Exception { private int httpCode = -1;