Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Samuel A.
Java Email
0 Answer(s)      2 years and 8 months ago
Posted in : JavaMail


i am writting a program to send emails using gmail smtp server. I had the following error: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/MessagingException at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) Exception in thread "main" Java Result: 1 BUILD SUCCESSFUL (total time: 6 seconds) Could anyone help me correct this? here is the code:

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package JavaMail;

import MISC.Repository; import java.util.Properties; /* import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; */ import javax.mail.*; import javax.mail.internet.*; /** * * @author Aileen */ public class SendMail {

String username;
String password;
String mailServer;

Session session;
Message message;

public SendMail (String mServ, String un, String pw) {

    username = un;
    password = pw;
    mailServer = mServ;

    Properties props = new Properties ();
    props.put("mail.smtp.host", mailServer);
    props.put("mail.smtp.socketFactory.port", "465");
    props.put("mail.smtp.socketFactory.class",
                "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.port", "465");

    session = Session.getDefaultInstance(props,
        new javax.mail.Authenticator() {
        @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username,password);
            }
        });
}

public void setFields (String sub, String msg, String hName, String hVal) {
    try {
        message = new MimeMessage(session);

        message.setHeader(hName, hVal);
        message.setSubject(sub);
        message.setText(msg);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

public void mailer (String from, String to) {
    try {
        message.setFrom(new InternetAddress (from));
        message.setRecipients(Message.RecipientType.TO,
                InternetAddress.parse(to));
        Transport.send(message);
        Repository.showMessage("Message Successfully Sent to "+to, "SUCCESS", 'P');
    }catch (Exception ex) {
        throw new RuntimeException(ex);
    }

}

public static void main (String args[]) {
    SendMail sm = new SendMail ("smtp.gmail.com", "elimence", "awonkyarok");
    sm.setFields("HELLO", "DOES IT WORK", "HEADER", "HEADER VALUE");
    sm.mailer("Sector 7", "fancymastaflexx@yahoo.co.uk");
}

}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Java Email
Java Email  I am making one java email applications using jsp-servlets. can you tell me that how can i recieve and send email dynamically in my application in UI... thanx.   Hi, Please read at Email From JSP &
Java Email
Java Email  i am writting a program to send emails using gmail smtp server. I had the following error: java.lang.ClassFormatError: Absent Code...) Exception in thread "main" Java Result: 1 BUILD SUCCESSFUL (total time: 6 seconds
Advertisements
email extractor - Java Beginners
email extractor  how to extract only email address from a lines of text file(.txt or .doc) and print in another file? will u send me answer in c...; Sorry! I am a java developer.It's been long time that i left 'C
email extractor - Java Beginners
email extractor  how to extract only email address from a lines... queries. /** * Program to scan email address from a file and write into an other..."; String line = null; String email=""; try { File file = new File
java code to send an email
java code to send an email  i developed one java code that has to send a mail but i am getting an runtime exception calledjavax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465; nested
email
email   hi I am using 1and1 server. Using this server i am sending a mail using java program . But it is running some problem occur " Cannot send email. javax.mail.SendFailedException: Invalid Addresses; nested exception
email
email  how do i code for making clicking a send button sends a email
javascript-email validation - Java Beginners
javascript-email validation  give the detail explanation for this code: if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr... about email validation at: http://www.roseindia.net/jsp/valid-email-jsp.shtml
sending email using smtp in java
sending email using smtp in java  Hi all, I am trying to send and email to through my company mail server. Following is my code package com.tbss; import javax.mail.*; import javax.mail.internet.*; import
How to send and recieve email by using java mailserver
How to send and recieve email by using java mailserver  How to send and receive email by using java mail server?   Hi Friend, Please visit the following link: Java Mail Thanks
Digitally signing email through Java mail api
Digitally signing email through Java mail api  how to sign (Digital Signature) one message using Java mail api
Email Validation code - Java Interview Questions
Email Validation code  Can anybody tell me how to write email validation code using java   Hi Friend, Please visit the following link: http://www.roseindia.net/tutorial/java/core/regularExpressions.html Thanks
validation of date,phone number,email - Java Beginners
number and email in java swings  Hi Friend, Try the following code...: "); t2=new JTextField(20); l3=new JLabel("Enter Email: "); t3=new...) { String email=t3.getText(); String exp="^[\\w\\-]([\\.\\w])+[\\w]+@([\\w
java code to send email using gmail smtp server
java code to send email using gmail smtp server  please send me the java code to send email using gmail smtp server. and how to send verification code
how to send sms on mobile and email using java code
how to send sms on mobile and email using java code  hi.... I am developing a project where I need to send a confirmation/updation msg on clients mobile and also an email on their particular email id....plz help me to find
email archiving
email archiving  Hi, What is email archiving? Thanks
Change Email
Change Email  Hi, I need to change my Rose India register email address for receive email, How did it possible
email validation
email validation  during email validation.... after domain name which it means if example example@gmail.co .... this address allowed by any validation program .... but i want to show invalid email address because domain name com
email validation
email validation  during email validation.... after domain name which it means if example example@gmail.co .... this address allowed by any validation program .... but i want to show invalid email address because domain name com
Email sending
Email sending  Hi sir, Am doing a project, in that i need to send email to multiple recipients at a same time using jsp so send me the code as soon as possible. Regards, Santhosh
JSP Email
JSP Email  Hi, How to send email using JSP? Thanks   Hi, Check this tutorial: Send Email to selected dropdown user Thanks
send email with attachments in servlet
send email with attachments in servlet  How can we send an email with attachments in servlet?   Send attached email in Java Servlet
email search code in php
email search code in php  email search with multiple option in php
How can i extract email ids from xls/xlsx file in java?
How can i extract email ids from xls/xlsx file in java?  that's the code..... i tried to extract email id;s from xls file........... but it doesn;t gives the proper output? table is like this: bhavik
code for email - Spring
code for email  i want a java code using springs after login process sending an email to the corresponding with a text message to them as successfully registered  Hi Friend, Please visit the following links: http
Search engine for email
Search engine for email  Build a search engine which will look at your email inbox and sort your email into 5 or more bins according to some criteria (e.g. date, email address, text of the email
How does Email works
to deliver Email to the recipient mail server. Java mail Application communicates... How does Email works       Each Internet domain has email Server, when a user sends
HTML email example
HTML email example  Hi, I am looking for an email to open email composer when user clicks on the email link. Give me code for html email example... for opening the email client when user clicks on the email link. Here is the example
javascript regex validation email
validation for email?   <html> <head> <title>Email...; function validate() { var email = document.getElementById("email").value...}$/; if (emailPattern.test(email)) { alert("Email Id: " + email
Email Archive - What is Email Archive?
Email Archive In this section we will see what is email archive and how it is useful in securely storing your email communications. These days almost all the internet users and companies are using email as communication means
jQuery email validation
jQuery email validation  Hi, I am using jQuery in my PHP based web application. I have to validate the email address entered by user on the form. I also want to display the error message in red color if email address
 

 

 

DMCA.com