Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

Email User with attachemnt program

Hi,

I am looking for a sample java progam which emails user with simple excel or text file attachemnt from local machine say C drive.
Any ideas, suggestions, sample code, links, source code highly appreciated. Thanks in advance
Avatar of gudii9
gudii9
Flag of United States of America image

ASKER

I tried this example from bel;ow link

http://www.tutorialspoint.com/java/java_sending_email.htm

getting error like

javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
  nested exception is:
      java.net.ConnectException: Connection refused: connect
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
      at javax.mail.Service.connect(Service.java:295)
      at javax.mail.Service.connect(Service.java:176)
      at javax.mail.Service.connect(Service.java:125)
      at javax.mail.Transport.send0(Transport.java:194)
      at javax.mail.Transport.send(Transport.java:124)
      at com.phh.SendEmail.main(SendEmail.java:51)
Caused by: java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
      at java.net.Socket.connect(Socket.java:529)
      at java.net.Socket.connect(Socket.java:478)
      at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:288)
      at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:231)
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1900)
      ... 7 more
please advise
Avatar of gudii9

ASKER

I tried this example from below link

http://www.roseindia.net/javamail/Introduction-to-Java-Mail-API.shtml

>>>Download the JAF 1.1 zip from the link given below:

>>http://java.sun.com/javase/technologies/desktop/javabeans/jaf/downloads/index.html

>>Steps to install Java Beans Activation Framework

>>Unzip the jaf-1_1_1.zip archive.
>>Set CLASSPATH to include the "activation.jar" file obtained from the download

I could not find the activation jar in the downloaded zip to be included in the classpath. Please advise
Avatar of gudii9

ASKER

I even tried this program

http://www.roseindia.net/javamail/SendAttachment.shtml


which is also not working. Please advise
ASKER CERTIFIED SOLUTION
Avatar of Pramod Kumar
Pramod Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Agree with pramodkrjsr. Try his solution.