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




Have Programming Question? Ask it here!
 
 
 


Samuel A.
Java Email
0 Answer(s)      2 years and 7 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
JSP Email
JSP Email  Hi, How to send email using JSP? Thanks   Hi, Check this tutorial: Send Email to selected dropdown user Thanks
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
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
Autodownload email attachments
Autodownload email attachments  I'm able to download attachments if my inbox has an unread email with predefined subject.I'm wondering if I can do the same as soon as I receive an email i.e.,Is there any way to run this program
validate email objective c
validate email objective c  how can i validate email text field in objective c? is there any method that support multiple email address separated by coma.   - (BOOL)validateEmailWithString:(NSString*)email
semantic email addressing
semantic email addressing  i am in final year of engineering . how can i implement semantic email addressing? please guide me. thanks in advance
sends me email
sends me email  How do I create a link that sends me email
validating email id
validating email id  how to validate the email id ?   <...('email').value; var regExpObj = /(\d\d\d)-\d\d\d\d\d\d\d\d/; var reg... = document.getElementById('email').value; if(reg.test(e) == false
generate Email - JSP-Servlet
generate Email  Hi I need to generate an automated email and need to send it to the client like an confirmation email after registering to my website...-an-email-in-jsp.shtml Thanks
email entire page javascript
email entire page javascript  How to email entire page in JavaScript without using OB?   ob_end_start(); // page content if(!empty($_GET['purpose']) && $_GET['purpose'] == "email") { $message = ob_get
struts2 email code
struts2 email code  when I tried the code of sending email suggested by you on when I tried the code of sending email suggested by you on giving following exception. com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must
regarding email - Development process
regarding email  Hi I want to generate an Email automatically after... mentioned that you want to send email after registration. You can do this by calling the Send mail servlet. For sending email please visit the following link
email problem - JavaMail
email problem  hi,i want to write a code for sending a mail... should have the email id of only 1 employee only(means he will not able to know who other is the reciever of email.).i m trying to do this by writing mail code
Sending email without authentication
Sending email without authentication  Hi sir, Am doing a project in JSP, in that i want to send mail without any authentication of password so send.../mail/sending-an-email-in-jsp.shtml
HTML - Email example
HTML - Email example Description : There is not any specific tag for email..."  on the place of URL. If email client(Outlook Express, Netscape... email tag.</h1> <p>Please click on this link and send mail to me
how to send email
how to send email  hii i am new for jsp-servlet and i am making a project in jsp-servlet. i want to send the email after registration to client.please send me code that how to send mail after client registration. thank you
Sending an email in JSP
Sending an email in JSP       Sending an email in JSP In this section, you will learn how to send an email in jsp.   Following is a simple JSP page for sending
email confirmation - Hibernate
email confirmation  Hello, I red with great interest your articles about integration of Hibernate and JSF and Spring, and I need to add some more... email link after that I should read user data from hibernate/MySql and make some
Validate email id in jsp - JSP-Interview Questions
Validate email id in jsp  Hi Please Suggest me how to validate email id in JSP(Java Server Faces
JavaScript Email Validation
JavaScript Email Validation...; In this section we are going to check email Validation using JavaScript. JavaScript allows to perform a client side validation of email Ids in several forms
sending automatic email - JavaMail
sending automatic email  Dear sir. In my project i need to send an automatic email to the clients when their accounts are going to expire in 30 days.i am using jsp,mysql and tomcat for my project.Expire information are stored
Email - Electronic mail
Email - Electronic mail In this article we will understand the E-mail and see how it works? Now a days email is integral part of day to day life for all internet users. We prefer email over standard mail. Email is free
Advertisements
 

 

 

DMCA.com