Hi i am unable to send mail from yahoo mail id.can any one help on this?
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.*;
import java.util.Properties;
public class MailClient
public void sendMail(String mailServer, String from, String to,
String subject, String messageBody,
String[] attachments) throws
MessagingException, AddressException
// Setup mail server
Properties props = System.getProperties();
props.put("mail.smtp.host", mailServer);
// Get a mail session
Session session = Session.getDefaultInstance(props, null);
// Define a new mail message
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(subject);
// Create a message part to represent the body text
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(messageBody);
//use a MimeMultipart as we need to handle the file attachments
Multipart multipart = new MimeMultipart();
//add the message body to the mime message
multipart.addBodyPart(messageBodyPart);
// add any file attachments to the message
addAtachments(attachments, multipart);
// Put all message parts in the message
message.setContent(multipart);
// Send the message
Transport.send(message);
protected void addAtachments(String[] attachments, Multipart multipart)
throws MessagingException, AddressException
for(int i = 0; i<= attachments.length -1; i++)
String filename = attachments;
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
//use a JAF FileDataSource as it does MIME type detection
DataSource source = new FileDataSource(filename);
attachmentBodyPart.setDataHandler(new DataHandler(source));
//assume that the filename you want to send is the same as the
//actual file name - could alter this to remove the file path
attachmentBodyPart.setFileName(filename);
//add the attachment
multipart.addBodyPart(attachmentBodyPart);
public static void main(String[] args)
try
MailClient client = new MailClient();
String server="pop3.yahoo.com";
String from="[email protected]";
String to = "[email protected]";
String subject="Test";
String message="Testing";
String[] filenames = {"c:\\gopi.txt"};
client.sendMail(server,from,to,subject,message,filenames);
catch(Exception e)
e.printStackTrace(System.out);
while compliling this one its compiled succesfully but i am getting exception at run time like..D:\mail>java MailClient
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/activation/re
gistries/MailcapFile
at javax.activation.MailcapCommandMap.loadFile(MailcapCommandMap.java:275)
at javax.activation.MailcapCommandMap.<init>(MailcapCommandMap.java:128)
at javax.activation.CommandMap.getDefaultCommandMap(CommandMap.java:44)
at javax.activation.DataHandler.getCommandMap(DataHandler.java:136)
at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:568)
at javax.activation.DataHandler.getContent(DataHandler.java:501)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1253)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2012)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1980)
at javax.mail.Transport.send(Transport.java:97)
at MailClient.sendMail(MailClient.java:35)
at MailClient.main(MailClient.java:72)
can any one help on this....plz
thanks in advance
Edited by: Konapalli.Gopi on May 20, 2010 5:42 PM
Something's wrong with your CLASSPATH.
If you're not using JDK 6, you need to include activation.jar in your CLASSPATH.
If you've got any other jar files that define the javax.mail.* or javax.activation.* classes
in your CLASSPATH (such as javaee.jar or j2ee.jar), remove them.
Similar Messages
-
I've deleted my mail app from my macbook pro can anyone help me get this back or how to retore it please?
What version of OS X, please?
-
Over the last few days I haven't been able to download any app. can any one help me, please ? thank you.
Andrea...
You posted in the "Using Mac App Store" forum but your profile indicates you are using an iPad so that's what I'll try helping you with.
On the iPad tap Settings > General > Reset > Reset Network Settings
Then restart the iPad. Hold the On/Off Sleep/Wake button down until the red slider appears. Slide your finger across the slider to turn off iPhone. To turn iPhone back on, press and hold the On/Off Sleep/Wake button until the Apple logo appears.
If you still can't download apps, the problem may be your Wi-Fi connection > iOS: Troubleshooting Wi-Fi networks and connections -
Safari keeps crashing every time I try to open a link from a different application, i.e. Mail. The trouble report says that some problem occurs with libcooliris.dylib plug-in. Can any one help?
Thanks!Dear Linc,
Thank you for the advice, John Blanchard1 and Linc Davis
As suggested in your reference thread I removed "/Library/Printers/hp/PDEs/hpPostScriptPDE.plugin" and the problem has been resolved.
I am guessing the the plug-in for the hp printers got corrupted and effected every thing, or became unsuitable when I installed an Apple update. I would be most grateful if you can confirm how the problem was coursed so I can understand and learn from this experiance.
Ash -
hi my account was locked for some security reasons and i forget the securicty questions and when i am trying to reset my password through email i am not gettig mail to my id can any one help.
<Edited by Host>Have you checked Spam? I have noticed recently in my Gmail that Google sends some mails from Apple to the Spam folder.
<Edited by Host> -
Can any one help me sending Oracle application server Cloning document 9.0.4 version
Can any one help me sending Oracle application server Cloning document 9.0.4 version (Mail id removed by moderator)
Many Thanks in advance
DeepakHi Deepak,
In first place application server 9.0.2 is desupported since 30th June 2007.So oracle would always recommend its customer to be on the latest versions.
Please follow the below URL for cloning Appplciation Server 9.0,.4
Cloning Application Server Middle-Tier Instances
Regards,
Prakash. -
Am unable to insert table and graphs into word document in labwindow/CVI? can any one help me ?
Are you using the Word Report Generation instrument? You can find it in toolslib\activex\word\wordreport.fp under the CVI directory.
The instrument comes with a sample project that shows how to include table and graphs in a Word document: see samples\activex\word\wordrpt.cws in the samples foder of your CVI installation.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
I rubbed the iTunes gift card back off, I was unable to read the serial number as part of it came off, can any one help.
If the page that you posted from doesn't help then you will need to try contacting iTunes support (you will need to give them as much of the serial number and activation code from the card as you can read) : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then iTunes Cards And Codes
-
I'm not able to copy and paste files from my mac to hard disk and usb. I have tried dragging the items I want to copy to those devices but it won't work. I also have tried copying and pasting those files onto those devices too but that doesn't work too. Can any one help?
Hi BobRz
Thanks for you suggestion but it didn't work - are there other ways for solving this problem? Or is it because my files that I want to copy and paste onto my hard disk etc are too big? (However there is space on my hard disk and it works on a PC) -
Hello i am having a problem in my 4s that it dosent run any USSD code it goes on calling , can any one help me i am maqsood from Karachi Pakistan
Ok so I've done what you said and this is what it's come back ....
I don't know that these are the errors , but they're the things which don't look right ...
Throughout the shut down there is a recurring line ;
It says ;
Com.apple.launchd 1 0x100600e70.anonymous.unmount 301 PID still valid
Then there are 2 more which I think are related ;
Com.apple.securityd 29 PID job has I overstayed its welcome , forcing removal.
Then the same with fseventd 48 and diskarbitrationd 13
Oh and on Launchd1 : System : stray anonymous job at shut down : PID 301 PPID13 PGID 13 unmount...
Then the last process says "about to call: reboot (RB_AUTOBOOT).
Continuing...
And stops ...
Hope this means something to you ... Thanks again for your help so far :-) -
when i was trying to update my iphone 4s from 6.1.4 to ios 7,its asking to change the media sync options,how can i change that option,can any one help me.........?
I tried powering down and re-starting the iPhone (as suggested at http://support.apple.com/kb/TS1275). This seems to have cleared the "...not connected to the Internet" problem, and iOS 6.1 is now in the process of downloading.
Thanks very much for your feedback. -
My Iphone 4s reciever is not working properly, when i call someone from my iphone 4s. can any one help me how to solve this problem?
You might like to define "not working properly".
-
i want to create org data profile in service scenario, with price determination from sales org, distribution centre , can any one help me with these
IF I CREATE SERVICE ORG WITH SERVICE SCENARIO ORG DATA PROFILE,
MY PRICING IS NOT GETTING DETERMINED AS IT IS LINKED TO SALES ORG AND DISTRIBUTION CHANNEL THROUGH PRICING DETERMINATION SO HOW TO DO THE CUSTOMIZATION FOR THIS SITUATION
WITH REGARDS,
SATHISHHi Satish,
Please assign the org det. rules to org det. profile with Sales and Service scenarios and then assign the org. det. profile to transaction type. The below screenshot is just for your reference.
Hope it would fix your issue.
Regards, -
Help me, I am using flash pro cc and air 4.0,i have one problem when publishing apk through air publish settings,choosing the run time option from third party is disabled.
can any one help me bcoz i have to publish without air runtime.......Hi,
This option is available when your publish target is set to AIR 3.6.
You can download the desired AIR SDK version from Archived Adobe AIR SDK versions
Thanks!
Mohan -
Downloaded yosemite and mail application not responding? will not open can any one help?
downloaded yosemite and mail application not responding? will not open can any one help?
Restart the machine in Safe Mode and attempt to open each app. Also please explain exactly how you are attempting to open the apps. For example, "When I click the Safari icon on the Dock it bounces but does not open." To start in Safe Mode hold down the Shift key when you hear the startup tone unitl a progress bar appears.
Maybe you are looking for
-
Report Layout in report Painter
I created a Report in reportPainter. In the report layout, lead column section..I select Group Name to display the group name (set's id) in the report's lead column but not all the set's keys appear. It only appears children's ids but not the father'
-
I recently changed apple ids on my iphone and now can not update or download any apps
I recently had an issue with my apple id and icould. I deleted my original apple id and made a new one with my new email address. I updated my phone with the info but now cannot update any apps on my phone and I cannot download any new apps? HELP!!!!
-
Getting the error while loading the master data
Hi i have tried to delete the master data using right click and delete master data, but still there are data. Now i am trying to load this master data again then i am getting the message "0 from 50033 records" and data load got failed with error mess
-
does anyone know of an adapter that will go between a monitor's video cable and the mac vga adapter that will allow video to both the mac's monitor and another screen? I am trying to make it to where I can have my mac be my dvd player and work with m
-
Scripts for CS6 Scripting Guide
The link in the PDF document "Adobe InDesign CS6 Scripting Guide:Javascript" is broken and I can't find the file with the example javascripts. Can you help? /f