Samuel A.
Java Email
0 Answer(s)      a year and 4 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");
}

}

View Answers









Related Pages:
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
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
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
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
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
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
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
email
email  how do i code for making clicking a send button sends a 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
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
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
regarding email - JavaMail
that object. For read more information on Java Mail visit to : http
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
Sending email with read and delivery requests
Sending email with read and delivery requests  Hi there, I am sending emails using JavaMail in Servlets on behalf of a customer from the website...   To read a mail, visit the following link: Java Read Mail
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
how to send contact detail in email
%"><b>Email:</b></td> <td width="100%"><input type="text" name="email" size="50"></td> </tr> <tr>...;/html> and this is my jsp page.... <%@ page language="java
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
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 validation is JSP using JavaScript
Email validation is JSP using JavaScript... will show you how to validate email address in you JSP program using JavaScript. In most of the application there is a need to validate email address on the form
email archiving
email archiving  Hi, What is email archiving? Thanks
Send Email From JSP & Servlet
J2EE Tutorial - Send Email From JSP & Servlet... (java servlet development kit).  (We are using Tomcat server. ...;  TOMCAT_HOME=C:\TOMCAT   >SET  JAVA_HOME=C
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
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
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
Sending Email with Attachment
Sending Email with Attachment     ... java mail api. A client create new message by using Message subclass. It sets... the Transport.send() method. By this code you can get functionality to send Email
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
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
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
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