If Java was a person, I would have killed them already....[JavaMail Help]

Discussion in 'Web Design and Development' started by yg17, Aug 4, 2006.

  1. yg17 macrumors G5


    Aug 1, 2004
    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:

    Properties props = new Properties ();
            props.put("mail.smtp.host", "smtp.----.com");
            Session sendMailSession;
            sendMailSession = Session.getInstance(props);
            Message newMessage = new MimeMessage(sendMailSession);
            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:

    <%@ 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
  2. jsw Moderator emeritus


    Mar 16, 2004
    Andover, MA
    I believe it's MimeMessage.RecipientType or Message.RecipientType or something like that, not just RecipientType (so, for example, "MimeMessage.RecipientType.TO").
  3. yg17 thread starter macrumors G5


    Aug 1, 2004
    St. Louis, MO

    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.

Share This Page