Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yg17

macrumors Pentium
Original poster
Aug 1, 2004
15,030
3,009
St. Louis, MO
Argh.....this is why I love PHP. I'm just having one roadblock after another with damn Java. But my job insists I use Java, so.....

Anyways....I'm using Javamail in my JSP, and get this error:

RecipientType.TO cannot be resolved to a type

Here's my code:

Code:
Properties props = new Properties ();
        props.put("mail.smtp.host", "smtp.----.com");
        Session sendMailSession;
        sendMailSession = Session.getInstance(props);
        Message newMessage = new MimeMessage(sendMailSession);
        newMessage.setSubject("----");
        newMessage.setText("----");
        InternetAddress from = new InternetAddress("----@----.com");
        InternetAddress to = new InternetAddress("----@----.com");
        newMessage.addRecipient(to, RecipientType.TO);

I know it's not complete, but I was adding lines 1 by 1 until I got that error, so I'm stuck there.

My import is:

Code:
<%@ page import="java.sql.*,javax.sql.*,java.io.*,javax.naming.*, Encrypt.*, java.util.*, javax.mail.*, javax.mail.internet.*, javax.activation.*" %>

and I have activation.jar and mail.jar in my WEB-INF\lib directory. I'm using Tomcat 5.5 on XP (ugh....wish I could bring my PowerBook to work. Damn "no computers except ours on the company network" policy).

thanks in advance
 
I believe it's MimeMessage.RecipientType or Message.RecipientType or something like that, not just RecipientType (so, for example, "MimeMessage.RecipientType.TO").
 
jsw said:
I believe it's MimeMessage.RecipientType or Message.RecipientType or something like that, not just RecipientType (so, for example, "MimeMessage.RecipientType.TO").


Thanks, I got it :D

Turns out, the tutorial I was copying and pasting from had that line all messed up. Some tutorial indeed :rolleyes:

Now let's just hope the SMTP server actually works. We use Exchange, so I'm not sure if there's an SMTP server for me to use. I'm just guessing at the server address.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.