G
Guest
Gast
Code:
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class JavMail
{
public static void postMail( String recipient,
String subject,
String message, String from )
throws [b]MessagingException[/b]
{
Properties props = new Properties();
props.put( "mail.smtp.host", "mail.java-tutor.com" );
[b]Session [/color][/b]session = [b]Session[/b].getDefaultInstance( props );
[b]Message [/b]msg = new [b]MimeMessage[/b]( session );
[b]InternetAddress [/b]addressFrom = new [b]InternetAddress[/b]( from );
msg.setFrom( addressFrom );
[b]InternetAddress [/b]addressTo = new [b]InternetAddress[/b]( recipient );
msg.setRecipient( [b]Message[/b].RecipientType.TO, addressTo );
msg.setSubject( subject );
msg.setContent( message, "text/plain" );
[b]Transport[/b].send( msg );
}
public static void main( String args[] ) throws Exception
{
postMail( "Buchtest@java-tutor.com",
"Tolles Buch",
"Wow. Das Buch ist schön zu lesen",
"JavaTutor@java-tutor.com");
}
}
Ich habe folgendes Problem, dieser Quellcode will bei mir nicht laufen, die fetten Befehle ,bzw. die zwischen command werden in Eclipse rot martkiert. Bei den Packages steht "Never used". Im Habe über import die Dateien mail.jar (javamail-1_3_3-ea) und activation.jar (jaf-1_0_2-upd2) importiert. Bei Windows XP habe ich unter Systemsteuerung->Umgebungsvariablen->Path den Pfad ( C:\Programm\java ) eingetragen. Ich benutze Java 1.5 und Eclipse 3.0.