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

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #1
    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
     
  2. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #2
    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

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #3

    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