Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem In Java Mail

Status
Not open for further replies.

Hattusas

Programmer
Nov 11, 2001
344
TR
In my J2EE application I need to send faxes.Our fax server is Right Fax software and this software allows us to send faxes prepared by e mail.
All you have to do is writing the mail address in tihs format
<your-name>@<your fax number>@fax server name.

For this reason I will use java mail api but this api does not allow me the syntax above.

(Gives the javax.mail.internet.AddressException: Illegal character in domain in string ``Hattusas@02122968599@RFAX'' for example, when I type
addressTo[0] = new InternetAddress(&quot;Hattusas@02122968599@RFAX&quot;);
msg.setRecipients(Message.RecipientType.TO, addressTo);
)
here is my complete syntax all about this:

try
{
boolean debug = false;

//Set the host smtp address
Properties props = new Properties();
System.out.println(&quot;hi!!!&quot;);
props.put(&quot;mail.smtp.host&quot;, &quot;10.0.0.20&quot;);
//My e mail server's addresss
// create some properties and get the default Session
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);

// create a message
MimeMessage msg = new MimeMessage(session);

// set the from and to address
InternetAddress addressFrom = new InternetAddress(&quot;ssipahi@hotmail.com&quot;);
msg.setFrom(addressFrom);
InternetAddress[] addressTo = new InternetAddress[1];

addressTo[0] = new InternetAddress(&quot;Hattusas@02122968599@RFAX&quot;);

msg.setRecipients(Message.RecipientType.TO, addressTo);



// Setting the Subject and Content Type
msg.setSubject(&quot;Java Mail&quot;);
//msg.setContent(&quot;Content&quot;, &quot;text/plain&quot;);
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(&quot;Text Goes Here&quot;);

MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds = new FileDataSource(&quot;c:\\FAX\\1030353522031404D.html&quot;);
//My Attachment
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());

// create the Multipart and its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);

// add the Multipart to the message
msg.setContent(mp);

Transport.send(msg);
}
catch (Exception ex)
{
System.out.println(ex.toString());
}

Any suggestions? Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
 
Improvement on the problem:
I downloaded the javamail 1.3.
The javamail API on Websphere Application Server has a version of 1.2
I replaced my classpaths and instead of ,

addressTo[0] = new InternetAddress(&quot;Hattusas@02122968599@RFAX&quot;);

I used the syntax

addressTo[0] = new InternetAddress(&quot;Hattusas@02122968599@RFAX&quot;,false);
the API document says
&quot;If boolean variable is false, the detailed syntax of the address isn't checked.&quot;

But I couldn't escape from the same exception.

SOS!

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
openyourmind77@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top