473,782 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mail send problem using smtp

1 New Member
import javax.mail.*;
import javax.mail.inte rnet.*;
import java.util.*;
import javax.activatio n.*;
import javax.swing.tex t.*;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import javax.activatio n.DataSource;
import javax.mail.inte rnet.MimeMessag e;

/**
*
* @author rathit
*/
public class SendMail {

/** Creates a new instance of SendMail */
public SendMail() {
}
private class SMTPAuthenticat or extends javax.mail.Auth enticator{
public PasswordAuthent ication getPasswordAuth entication(){
String username = "Muni";
String password = "Raj";
return new PasswordAuthent ication(usernam e, password);
}
}
public void postMail() throws MessagingExcept ion {

boolean debug = false;
String recipients[] = {"java.muni@red iffmail.com"};
String recipientsCC[] = {"likhis_007@ya hoo.com"};

String subject = "Mail";
String message = "This is body for the message";
String from = "pop_muni@yahoo .com";
Properties props = new Properties();
props.put("mail .smtp.host","20 8.220.245.70");//mail.yahoo.com/68.142.225.208
props.put("mail .smtp.auth","tr ue");
Authenticator auth = new SMTPAuthenticat or();
Session session = Session.getDefa ultInstance(pro ps, auth);
session.setDebu g(debug);
MimeMessage msg = new MimeMessage(ses sion);
// set the from and to address
InternetAddress addressFrom = new InternetAddress (from);
msg.setFrom(add ressFrom);
InternetAddress[] addressTo = new InternetAddress[recipients.leng th];
for(int i = 0; i < recipients.leng th; i++){
addressTo[i] = new InternetAddress (recipients[i]);
}
msg.setRecipien ts(Message.Reci pientType.TO, addressTo);

//recipientsCC[]
InternetAddress[] addressCC = new InternetAddress[recipientsCC.le ngth];
for(int j = 0; j < recipientsCC.le ngth; j++){
addressCC[j] = new InternetAddress (recipientsCC[j]);
}
msg.setRecipien ts(Message.Reci pientType.CC, addressCC);

// Optional : You can also set your custom headers in the Email if you Want
msg.addHeader(" MyHeaderName", "myHeaderValue" );
msg.setSubject( subject);
msg.setContent( message,"text/html");
Transport.send( msg);
System.out.prin tln("Mail Successfully Sent");

}//End of postMail()
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws MessagingExcept ion {
// TODO code application logic here
new SendMail().post Mail();
}

}


when run
Exception in thread "main" java.lang.NoCla ssDefFoundError : javax/activation/DataSource
at test.SendMail.p ostMail(SendMai l.java:53)
at test.SendMail.m ain(SendMail.ja va:83)
Java Result: 1

pls help me
Jul 13 '07 #1
0 1640

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3097
by: Tom Petersen | last post by:
Ok, I'm 99.9999999999999999999% sure there haven't been any code changes, since the date stamps of the code are older than any email 'failures' The email piece quit working using the mail.send. If there haven't been any changes made to previously working code, where do I look for the problem now? I restarted the SMTPservice in IIS. Our real email is hosted remotely, I checked with the admin and she said no changes were made, i.e., not...
6
3260
by: John J. Hughes II | last post by:
I have a service that needs to send e-mail alerts. I have been attempting to use the System.Net.Mail function from .NET but this seems to require the IIS be installed and running. Since some of my customers are not really happy with having the IIS installed, not being used except to send e-mail this is becoming a problem. I have also tried using a little program from code project for sending e-mail which works great on older servers...
3
5588
by: dale zhang | last post by:
Hi, I write an asp.net web application. It has a “Contact Us” page, where users fill in their email, subject and text and hit send. Then the email will go to my hard coded yahoo email account. I was using optimum online service with smtp server as “mail.optonline.net”. I can receive email correctly. Now I switch to verizon DSL. I change my smtp server accordingly as
3
3036
by: RN | last post by:
I am tired of sending mail from the built-in SMTP service for so many reasons (errors are nondescriptive in the event log, it doesn't let me control which IP address it sends from, and it identifies itself as the computer name which is not in domain.com format, triggering spam filter problems). Instead, I want to have my code send through an SMTP server of a company that we pay for mail service. But they require a username and password....
9
3226
by: B-Dog | last post by:
I've built a small app that sends mail through our ISP's SMTP server but when I try to send through my local exchange server I get CDO error. Does webmail use SMTP or does it strictly rely on CDOmail. I don't want to use the Outlook reference because outlook prompts each time program access it and I have found a way to disable that. Can I use webmail with exchange? Thanks
1
8182
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to the members of my organization. I think my problem is incorrectly setting the settings on my server or an authentication problem. Here is the code I have written to send a test message: -----Code Begins: Sensitive Information Replaced by -----...
34
18271
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow "127.0.0.1". 4. Authentication: "Anonymous access" only. 5. Outbound connection listen to TCP 25. Besides,
1
2443
by: William Connery | last post by:
Hi, I have a small python program with e-mail capabilities that I have pieced together from code snippets found on the internet. The program uses the smtplib module to successfully send an e-mail with an attachment. I want to give users an indication of the percentage of the e-mail that has already been sent so as to avoid frustration when dealing with large attachments or a slow smtp server. But the smtplib module doesn't seem to...
4
7685
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
I have a web page that at the click of a button must send a bunch (1000+) emails. Each email is sent individually. I have the code working fine, using Mail Message classes and smtp and all that. But sometimes even when I'm just sending one e-mail the web page takes a minutes or so to post. Can anyone tell me why it is so slow, or how to fix the problem? To address this I am thinking of just creating a queue table to write the emails...
11
3516
by: Ed Bitzer | last post by:
I have been able using the namespace System.Web.Mail and its method Smtp.mail.send to mail simple text messages to a small group within our 55 and older community. I need help expanding the programs capabilities. Searching this forum I did not find any related information so if I have chosen poorly, I would appreciate a suggestion of a more appropriate dotnet forum. Now what I wish is the ability to send bcc's rather than to: (would be...
0
9479
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9942
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8967
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.