eMail versenden

  • Themenstarter Themenstarter Guest
  • Beginndatum Beginndatum
Status
Nicht offen für weitere Antworten.
G

Guest

Gast
Hallo zusammen,

ich beschäftige mich gerade mit dem versenden von eMails. Ich benutze dafür folgenden Code:
Code:
package email;

import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.Transport;

public class JavaMail {

	public static void main (String args[]) throws Exception {

	String smtpHost = "mail.gmx.net";
	String popHost = "pop.gmx.net";
	String from = "name@gmx.net";
	String to = "name@gmx.de";
	String username = "name@gmx.de";
	String password = "xxx";

	// Get system properties
	Properties props = System.getProperties();

	// Setup mail server
	props.put("mail.smtp.host", smtpHost);

	props.put("mail.smtp.auth", "true");

	// Get session
	Session session = Session.getDefaultInstance(props, null);
	//Gibt in auf der Console Meldungen zum Verlauf des Sendens aus
	session.setDebug(true);

	// Pop Authenticate yourself
	Store store = session.getStore("pop3");
	store.connect(popHost, username, password);


	// Define message
	MimeMessage message = new MimeMessage(session);
	message.setFrom(new InternetAddress(from));
	message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
	message.setSubject("Hello JavaMail");
	message.setText("Welcome to GMX JavaMail");


	// Send message
	//Transport.send(message);
	store.close();
	}
}

Ich bekomme dann folgende Meldung:
Code:
...
S: +OK Mailbox locked and ready
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
Exception in thread "main" javax.mail.AuthenticationFailedException
	at javax.mail.Service.connect(Service.java:306)
	at javax.mail.Service.connect(Service.java:156)
	at javax.mail.Service.connect(Service.java:105)
	at javax.mail.Transport.send0(Transport.java:168)
	at javax.mail.Transport.send(Transport.java:98)
	at email.JavaMail.main(JavaMail.java:46)

Was mache ich falsch???
 
Hallo Herr Gast

Musste auch ein bisschen rumprobieren...aber mittlerweile hats geklappt.

Was bei deinem Programm noch fehlt ist ein sogenannter Authenticator. Das ist ein Klasse die du definierst und
die von javax.mail.Authenticator erben muss. Diese Klasse muss die Methode getPasswordAuthentication() implementieren; das ist nämlich die Methode, die aufgerufen wird bei der Überprüfung deines GMX-Accountes. Die Klasse sieht dann ungefähr so aus:
Code:
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;


public class MyAuthenticator extends Authenticator {

	private PasswordAuthentication pa;
	
	public MyAuthenticator(String name, String password) {
		this.pa = new PasswordAuthentication(name, password);
	}
	@Override
	protected PasswordAuthentication getPasswordAuthentication() {
		return this.pa;
	}

}

Nun musst du noch eine Instanz dieser Klasse entsprechend deiner Session mitgeben, das funktioniert folgendermassen:
Code:
...
MyAuthenticator auth1 = new MyAuthenticator(username, password);
		
		// Get session
		Session session = Session.getDefaultInstance(props, auth1);
		session.setDebug(true);
...

So, und wenn du das Ganze befolgt hast, dann klappts auch mit dem Nachbarn 😀

Grüsschen Elektryon
 
Hallo,
ich habe versucht alles zu machen was Elektryon gemacht hat.
Code:
//http://www.java2s.com/Code/Java/Network-Protocol/SendingMail.htm
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;

public class MailExample {
  public static void main(String args[]) throws Exception {
    String username = "flxxx@gmx.net";
    String password = "xxx";
    String smtpHost = "mail.gmx.net";
    String from = "flxxx@gmx.net";
    String to = "mxxx@web.de";

    // Get system properties
    Properties props = System.getProperties();

    // Setup mail server
    props.put("mail.smtp.host", smtpHost);
    MyAuthenticator auth1 = new MyAuthenticator(username, password); 
    // Get session
    Session session = Session.getDefaultInstance(props, auth1);
    session.setDebug(true);

    // Define message
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    message.setSubject("The Subject");
    message.setText("The Message");

    // Send message
    Transport.send(message);
  }
}

Code:
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;


public class MyAuthenticator extends Authenticator {

   private PasswordAuthentication pa;
   
   public MyAuthenticator(String name, String password) {
      this.pa = new PasswordAuthentication(name, password);
   }
   @Override
   protected PasswordAuthentication getPasswordAuthentication() {
      return this.pa;
   }

}

Aber leider bekomme ich jede Menge fehler beim versenden:
Code:
DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "mail.gmx.net", port 25, isSSL false
DEBUG SMTP: exception reading response: java.net.SocketException: Connection reset
Exception in thread "main" javax.mail.MessagingException: Exception reading response;
  nested exception is:
	java.net.SocketException: Connection reset
	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1611)
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
	at javax.mail.Service.connect(Service.java:288)
	at javax.mail.Service.connect(Service.java:169)
	at javax.mail.Service.connect(Service.java:118)
	at javax.mail.Transport.send0(Transport.java:188)
	at javax.mail.Transport.send(Transport.java:118)
	at MailExample.main(MailExample.java:32)
Caused by: java.net.SocketException: Connection reset
	at java.net.SocketInputStream.read(Unknown Source)
	at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
	at java.io.BufferedInputStream.fill(Unknown Source)
	at java.io.BufferedInputStream.read(Unknown Source)
	at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:88)
	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1589)
	... 8 more

Was mache ich falsch?
 
Mit Transport.connect() bekomme ich diese Fehlermeldung:
Code:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
	Cannot make a static reference to the non-static method connect() from the type Service

	at MailExample.main(MailExample.java:32)
 
Vermutlich ist die connect() methode nicht "static" und du musst eine Instanz von Transport anlegen?! Ein Blick in die API Doc sollte da helfen (Sorry, hab die Mail API auch noch nicht benutzt).

- Alex
 
Code:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;

public class MailExample {
  public static void main(String args[]) throws Exception {
    String username = "flxxx@gmx.net";
    String password = "xxx";
    String smtpHost = "mail.gmx.net";
    String from = "flxxx@gmx.net";
    String to = "mxxx@web.de";

    // Get system properties
    Properties props = (Properties)System.getProperties().clone();

    // Setup mail server
    props.put("mail.smtp.host", smtpHost);
    props.put("mail.smtp.connectiontimeout", "10000");
    props.put("mail.smtp.timeout", "10000");
    props.put("mail.smtp.port", "25");
    props.put("mail.smtp.user", username);
    props.put("mail.auth", "true");
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.store.protocol", "smtp");
    props.put("mail.host", smtpHost);
    props.put("mail.user", username);
    props.put("mail.debug", "true");

    // Get session
    Session session = Session.getInstance(props, new MyAuthenticator(username, password));

    // Define message
    MimeMessage message = new MimeMessage(session);

    Address fromAdr = InternetAddress.parse(from)[0];
    if (fromAdr != null) 
    {
        message.setFrom(fromAdr);
    }

    Address[] toAdr = InternetAddress.parse(to);
    if (toAdr != null) 
    {
        message.setRecipients(Message.RecipientType.TO, toAdr);
    }

    message.setSubject("The Subject");
    message.setText("The Message");

    // Send message
    Transport.send(message);
  }
}

Probier mal bitte den obigen Code aus.
Und nein, Du musst keine Instanz vom Transport Objekt anlegen.

Gruß
lhein
 
Mit dem neuen Code bekomme ich nun diese Fehlermeldung:
Code:
DEBUG: JavaMail version 1.4.1
DEBUG: not loading file: C:\Program Files\Java\jre1.6.0_04\lib\javamail.providers
DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jre1.6.0_04\lib\javamail.providers (The system cannot find the file specified)
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.providers
DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
DEBUG: Tables of loaded providers
DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
DEBUG: !anyLoaded
DEBUG: not loading resource: /META-INF/javamail.address.map
DEBUG: not loading file: C:\Program Files\Java\jre1.6.0_04\lib\javamail.address.map
DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jre1.6.0_04\lib\javamail.address.map (The system cannot find the file specified)
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "mail.gmx.net", port 25, isSSL false
DEBUG SMTP: exception reading response: java.net.SocketTimeoutException: Read timed out
Exception in thread "main" javax.mail.MessagingException: Exception reading response;
  nested exception is:
	java.net.SocketTimeoutException: Read timed out
	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1611)
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
	at javax.mail.Service.connect(Service.java:288)
	at javax.mail.Service.connect(Service.java:169)
	at javax.mail.Service.connect(Service.java:118)
	at javax.mail.Transport.send0(Transport.java:188)
	at javax.mail.Transport.send(Transport.java:118)
	at MailExample.main(MailExample.java:51)
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(Unknown Source)
	at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:110)
	at java.io.BufferedInputStream.fill(Unknown Source)
	at java.io.BufferedInputStream.read(Unknown Source)
	at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:88)
	at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1589)
	... 8 more

Ich verstehe nicht warum dieser Code in "C:\Program Files\Java\jre1.6.0_04\lib\" sucht, obwohl ich JavaMail in Eclispe eingebunden habe (Build Path-> Configure Build Path -> Libraries -> Add JARs).
 
Ich hab den Code eben nochmal getestet. Mit dem firmeneigenen Mailserver funktioniert es.
Wenn ich das ganze mit GMX probiere, geht es nicht. Da krieg ich die gleichen Fehler wie Du auch.
Hier ist es aber klar, weil der Port durch Firewall / Proxy geblockt ist. Kann es sein, dass das auch auf Dich zutrifft?

Was ich mir auch vorstellen könnte (aber eigentlich recht unwahrscheinlich ist) ist, dass Du erst POP vor SMTP machen musst.

lhein
 
Die Windows Firewall ist nicht angesprungen. Wie macht zuerst erst ein POP und ein SMTP?
 
Die Windows Firewall ist nicht angesprungen. Wie macht zuerst erst ein POP und ein SMTP?
 
Code:
ConfigurationIF config = SMTPConfiguration.createConfiguration("mail.gmx.net", 25, "????@gmx.ch", "?????");
Session session = Session.getDefaultInstance(System.getProperties());
Transport transport = session.getTransport("smtp");
transport.connect(config.getHost(), config.getPort(), config.getUsername(), config.getPassword());
Message message = //some mesasge;
transport.sendMessage(message, message.getAllRecipients());
transport.close();

habs so mal mit gmx probiert ...kein Problem (von mir zu Hause aus)
dh Emails kommen an
 
>> Die Windows Firewall ist nicht angesprungen. Wie macht zuerst erst ein POP und ein SMTP?

POP = Emails abrufen
SMTP = Emails senden

Ergo: Erst abrufen, dann senden.

Manche Emailprovider erfordern diese Reihenfolge (weil sie keine extra authentifizierung beim Senden haben).

- Alex
 
@Der Müde Joe: Leider bekomme ich dein Code nicht zum laufen:
Code:
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;


public class GmxMail {
	public static void main(String args[]) throws Exception {
	ConfigurationIF config = SMTPConfiguration.createConfiguration("mail.gmx.net", 25, "username", "password");
	Session session = Session.getDefaultInstance(System.getProperties());
	Transport transport = session.getTransport("smtp");
	transport.connect(config.getHost(), config.getPort(), config.getUsername(), config.getPassword());
	Message message = "Hallo";
	transport.sendMessage(message, message.getAllRecipients());
	transport.close();
	}
}

Und die Fehlermeldung sieht folgendermassen aus:
Code:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
	ConfigurationIF cannot be resolved to a type
	SMTPConfiguration cannot be resolved
	Type mismatch: cannot convert from String to Message

	at GmxMail.main(GmxMail.java:8)

Update: @lhein: du hattest recht, man muss zuerst pop und smtp machen:
Code:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.Transport;

public class JavaMail {

   public static void main (String args[]) throws Exception {

   String smtpHost = "mail.gmx.net";
   String popHost = "pop.gmx.net";
   String from = "xxx@gmx.de;
   String to = "xxx@gmx.de";
   String username = "xxxt";
   String password = "xxx";

   // Get system properties
   Properties props = System.getProperties();

   // Setup mail server
   props.put("mail.smtp.host", smtpHost);

   props.put("mail.smtp.auth", "true");
   
   MyAuthenticator auth1 = new MyAuthenticator(username, password); 
   // Get session
   Session session = Session.getDefaultInstance(props, auth1);
   //Transport transport = session.getTransport();
   //Gibt in auf der Console Meldungen zum Verlauf des Sendens aus
   session.setDebug(true);

   // Pop Authenticate yourself
   Store store = session.getStore("pop3");
   store.connect(popHost, username, password);


   // Define message
   MimeMessage message = new MimeMessage(session);
   message.setFrom(new InternetAddress(from));
   message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
   message.setSubject("Hello JavaMail");
   message.setText("Welcome to GMX JavaMail");


   // Send message
		Transport transport = session.getTransport("smtp");
		transport.connect(smtpHost, username, password);
		transport.sendMessage(message, message.getAllRecipients());
		transport.close();
   }
}
Vielleicht hat jemand verbesserungs vorschlaege.[/code]
 
flashdog hat gesagt.:
code]
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.Transport;

public class JavaMail {

public static void main (String args[]) throws Exception {

String smtpHost = "mail.gmx.net";
String popHost = "pop.gmx.net";
String from = "xxx@gmx.de;
String to = "xxx@gmx.de";
String username = "xxxt";
String password = "xxx";

// Get system properties
Properties props = System.getProperties();

// Setup mail server
props.put("mail.smtp.host", smtpHost);

props.put("mail.smtp.auth", "true");

MyAuthenticator auth1 = new MyAuthenticator(username, password);
// Get session
Session session = Session.getDefaultInstance(props, auth1);
//Transport transport = session.getTransport();
//Gibt in auf der Console Meldungen zum Verlauf des Sendens aus
session.setDebug(true);

// Pop Authenticate yourself
Store store = session.getStore("pop3");
store.connect(popHost, username, password);


// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Hello JavaMail");
message.setText("Welcome to GMX JavaMail");


// Send message
Transport transport = session.getTransport("smtp");
transport.connect(smtpHost, username, password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}
}
[/code]

Wenn ich mit diesem Code und
Code:
message.setFileName("c:\\demo.pdf");
versuche eine PDF-Datei zu versenden kommt die nur beschädigt beim Empfänger an. Weiss jemand wie ich das umgehen könnte?
Danke schonmal 🙂
 
am einfachsten:
Code:
Multipart multipart = new MimeMultipart();
MimeBodyPart part = new MimeBodyPart();
part.attachFile(file);
multipart.addBodyPart(part);
message.setContet(multipart);
 
Zuerst mal danke Joe 🙂

Also ich hab den Code von dir versucht, aber MimeBodyPart scheint kein attachFile() zu kennen, nur setFileName(). Wenn ich setFileName benutze fliegt mir allerdings ne IOExeption.

[/code]
 
>aber MimeBodyPart scheint kein attachFile() zu kennen
http://java.sun.com/products/javamail/javadocs/javax/mail/internet/MimeBodyPart.html#attachFile(java.io.File)

>fliegt mir allerdings ne IOExeption.

try..catch
 
nach einer woche immer noch nicht in der lage eine mail zu versenden. respekt für die leistung! :meld: :applaus:
 
Ok, ich glaub dir gerne, die api lügt ja nicht 🙁

Aber irgendwas mach ich falsch :/ Mein Eclipse ist fest der Meinung das es diese Methode nicht gibt. Ich benutz Java 1.5 und hab das auch unter Windows-Preferences-Java-Compiler so eingestellt. Laut api gibts die Methode seit 1.4. Ich hab das auch auf dem rechner von nem Kollegen hier ausprobiert, dessen eclipse sagt das selbe...
Was könnt das denn sein?

Ok, auf das Try-Catch hätt ich jetzt eigentlich selbst kommen müssen :?

Danke schonmal für die Hilfe bisher, Joe 🙂
 
Nein DP, ich bin heut erst über diesen Tread gestolpert. Ich nehm an du meinst den Treadöffner.
 
saugt dir die neuste jar....bind sie in Eclispe ein
http://java.sun.com/products/javamail/downloads/index.html

oder machs halt auf die altmodische art...(via DataSource)
von
http://java.sun.com/developer/onlineTraining/JavaMail/contents.html

Code:
// Define message
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, 
  new InternetAddress(to));
message.setSubject("Hello JavaMail Attachment");

// Create the message part 
BodyPart messageBodyPart = new MimeBodyPart();

// Fill the message
messageBodyPart.setText("Pardon Ideas");

Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);

// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);

// Put parts in message
message.setContent(multipart);

// Send the message
Transport.send(message);
 
Ich hab mir jetzt mal die Lib gezogen, und eingebunden. allerdings hab ich die alte mail.jar nicht finden können, die hätt ich dann ja auch gern rausgeworfen. Ich guck mal das ich das zum Laufen bekomme ohne die altmodeische Methode zu benutzen 🙂

Falls ich nicht druchkomme meld ich mich nochmal, bis dahin vielen Dank an alle Helfer 🙂
 
So, wenns jemand interessiert so hats dann funktioniert (bei mir zumindest)

Code:
		String smtpHost = "smtp.t-online.de"; 
		String username = "username"; 
		String password = "password";  
		String from = "me@host.de"; 
		String to = "to@host.de"; 
		String attachfile="C:\\demo.pdf";


		// Get system properties 
		Properties props = System.getProperties(); 
		props.put("mail.smtp.host", smtpHost); 
		props.put("mail.smtp.auth", "true"); 
		    
		MyAuthenticator auth1 = new MyAuthenticator(username, password); 
		   
		Session session = Session.getDefaultInstance(props, auth1); 
		session.setDebug(true);	//Gibt in auf der Console Meldungen zum Verlauf des Sendens aus

		try {
//			 Define message 
			Message message = new MimeMessage(session); 
			message.setFrom(new InternetAddress(from)); 
			message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); 
			message.setSubject("Hello JavaMail Attachment"); 

//			 Create the message part 
			BodyPart messageBodyPart = new MimeBodyPart(); 

//			 Fill the message 
			messageBodyPart.setText("Pardon Ideas"); 

			Multipart multipart = new MimeMultipart(); 
			multipart.addBodyPart(messageBodyPart); 

//			 Part two is attachment 
			messageBodyPart = new MimeBodyPart(); 
			DataSource source = new FileDataSource(attachfile); 
			messageBodyPart.setDataHandler(new DataHandler(source)); 
			messageBodyPart.setFileName(attachfile); 
			multipart.addBodyPart(messageBodyPart); 

//			 Put parts in message 
			message.setContent(multipart); 

//			 Send the message 
			Transport.send(message);
		} catch (NoSuchProviderException e) {
			e.printStackTrace();
		} catch (MessagingException e) {
			e.printStackTrace();
		}

Das mit dem Einbinden der jüngsten mail.jar hab irgendwie nicht geklappt. Ich hab sie zwar eingebunden bekommen, dennoch konnte ich die Methode attachFile nicht benutzen. Naja, so ist auch nicht mehr Code 🙂

Also, fettes Danke, Joe 🙂)
 
Da must du wohl erst die alte Lib entfernen

in Eclipse
rechte Maustaste aufs Projekt -> Properties --> Java Build Path --> Libraries

(dort solltes du alle fürs Projekt verwendeten libs finden)

Aber funktioniert ja auch so ..mfg
 
Ja, das hab ich mir auch gedacht, aber da hab ich nur die jre eingebunden, sonst nix.
Ich hab die mail.jar ja erst durch deinen Tip gezogen und eingebunden.
Da ich aber vorher schon den MimeBodyPart verwendet hab turnt der doch irgendwo in der jre rum,
oder seh ich da was falsch?

Auch wenn das mailen einwandfrei geht bringt mir das ja garnichts wenn ich
grad an so rudimentärem Probleme hab.
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben