How to read e-mail via java programming...
String host= "myhostname";
String user="myusername";
String pass= "mypassword";
Properties props =System.getProperties();
Session session =Session.getInstance(props,null);
Store store= session.getStore("imap");
System.out.println(store);
store.connect(host,user,pass)
this is my java program. when i run this i am getting the following error... but i can able to send the mail.
Exception in thread "main" javax.mail.MessagingException: Connection refused: connect;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:571)
at javax.mail.Service.connect(Service.java:288)
at javax.mail.Service.connect(Service.java:169)
at com.ebay.trinity.tps.EmailClient.main(EmailClient.java:25)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:107)
at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:538)
... 3 more
what could be the reason.. am i missing anything here. please help me..
Thanks in advance
Marimuthu.sp
this is my java program. when i run this i am getting the following error... but i can able to send the mail.See this thread, its just about 2 days old:
[http://forums.sun.com/thread.jspa?forumID=54&threadID=5349815]
Specially see Reply#4
Thanks!
P.S.: Its a good practice to search the forum for the problem you are facing before posting, because there a 50% chances that others might also have faced similar problems before.
Similar Messages
-
How to read system eventlog using java program in windows?
How to read system eventlog using java program in windows?
is there any java class available to do this ? or any one having sample code for this?
Your friend ZoeHi,
There is no java class for reading event log in windows, so we can do one thing we can use windows system 32 VBS script to read the system log .
The output of this command can be read using java program....
we can use java exec for executing this system32 vbs script.
use the below program and pass the command "eventquery"
plz refer cscript,wscript
import java.io.*;
public class CmdExec {
public static void main(String argv[]) {
try {
String line;
Process p = Runtime.getRuntime().exec("Command");
BufferedReader input =
new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
input.close();
catch (Exception err) {
err.printStackTrace();
This sample program will list all the system log information....
Zoe -
How to read system evenlog using java program in windows
How to read system evenlog using java program in windows???
is there any java class available to do this ? or any one having sample code for this?
Your friend ZoeWelcome to the Sun forums.
>
How to read system evenlog using java program in windows???>
JNI. (No.)
>
is there any java class available to do this ? or any one having sample code for this?>You will generally get better help around here if you read the documentation, try some sample code and come back with a specific question (hopefully with an SSCCE included).
>
Your friend Zoe>(raised eyebrow) Thank you for sharing that with us.
Note also that one '?' denotes a question, while 2 or more generally denotes a dweeb. -
How to read outlook mail using java
Hi,
I am new to javamail ,
I want to read outlook mail using java
thanks
Edited by: My_Problems on Jun 20, 2008 11:13 AMHi!
See Java Api Msgparser in GNU General Public License...
A parser for .msg Files in Java :
[http://auxilii.com/msgparser/|http://auxilii.com/msgparser/]
Use POI... Apache POI - Java API To Access Microsoft Format Files...
regards, -
How to read Korean characters using Java program?
In Oracle table, i am having Korean characters, how to read those characters using JDBC and insert into SQL Server?
NLS_NCHAR_CHARACTERSET is UTF8What data type is the column in the Oracle table? The NLS_NCHAR_CHARACTERSET would control the encoding of NCHAR and NVARCHAR2 columns. The NLS_CHARACTERSET would control the encoding of CHAR and VARCHAR2 columns.
Justin -
How to Read An Attachment Using Java Mail
Hi
I Am Able To Read The Mail Using Java Mail ,but Unable To Read The Attachment Which Comes Along With The Mail.
Please Help Me , In Reading The Attachment.Hi
I Am Able To Read The Mail Using Java Mail ,but
t Unable To Read The Attachment Which Comes Along
With The Mail.
Please Help Me , In Reading The Attachment.Do you mean:
- I only recieve .txt or .doc attachments and I want to see the contents? Or could you get a .jpg as well?
or
- Do you need to seperate the attachment from the e-mail and then view it? -
How to change system time through java program
Hi
I want to know, how to change system time through java program.
give me a idia with example.
ThanksThere isn't any core Java API for this. Use JNI or call an external process with Runtime.exec().
~ -
How to create batch job via a program
hi
i need to know how to create batch job via a program please suggest
aroraWow!
> Total Questions: 234 (138 unresolved)
...and now you ask this?
Please accept our apologies for not pointing out to you way-back-when already that there is a search functionality here at SDN and that the correct forum should be used to post questions to.
Please read "the rules" at the top of the forum page, and search first => ask questions later.
I take the liberty of closing your question for you.
Kind regards,
Julius -
How to read a mail from sap inbox thru abap code?
how to read a mail from sap INBOX thru abap code? can anyone tell me the technical approach? I NEED TO READ A MAIL and then need to pass the parameters to a bapi.
Message was edited by:
shahid mohammed syedHi SSM,
Did you manage to have your program working? I also have same requirement. I tried standard FM and BAPI but I always encounter authorization error when I tried accessing other user's mail. Thanks.
Regards,
Ryan -
Hello Experts,
I want to send mail via ABAP program with the following requirements :
1. Recipient is OUTLOOK email -id
2. Sender address has to be an external email-id
3. Send mail as CC and BCC also to other email-id.
Is there any function module which can satisfy all the above requirements.
Regards,
Mansi.hi,
this code will definately help you just go through it:
firstly exported the data to memory using the FM LIST_FROM_MEMORY.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE e000(su) WITH text-001.
ENDIF.
then i converted it into ASCII using LIST_TO_ASCI,
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_xlstab
listobject = t_listobject
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE e003(yuksdbfzs).
ENDIF.
This gives the data in ASCII format separated by '|' and the header has '-', dashes. If you use this internal table directly without any proccesing in SO_NEW_DOCUMENT_ATT_SEND_API1, then you will not get a good excel sheet attachment. To overcome this limitation, i used cl_abap_char_utilities=>newline and cl_abap_char_utilities=>horizontal_tab to add horizontal and vertical tabs to the internal table, replacing all occurences of '|' with
cl_abap_char_utilities=>horizontal_tab.
Set the doc_type as 'XLS', create the body and header using the packing_list and pass the data to be downloaded to SO_NEW_DOCUMENT_ATT_SEND_API1 as contents_bin.
This will create an excel attachment.
Sample code for formatting the data for the attachment in excel format.
u2022 Format the data for excel file download
LOOP AT t_xlstab INTO wa_xlstab .
DESCRIBE TABLE t_xlstab LINES lw_cnt.
CLEAR lw_sytabix.
lw_sytabix = sy-tabix.
u2022 If not new line then replace '|' by tabs
IF NOT wa_xlstab EQ cl_abap_char_utilities=>newline.
REPLACE ALL OCCURRENCES OF '|' IN wa_xlstab
WITH cl_abap_char_utilities=>horizontal_tab.
MODIFY t_xlstab FROM wa_xlstab .
CLEAR wa_xlstab.
wa_xlstab = cl_abap_char_utilities=>newline.
IF lw_cnt NE 0 .
lw_sytabix = lw_sytabix + 1.
u2022 Insert new line for the excel data
INSERT wa_xlstab INTO t_xlstab INDEX lw_sytabix.
lw_cnt = lw_cnt - 1.
ENDIF.
CLEAR wa_xlstab.
ENDIF.
ENDLOOP.
Sample code for creating attachment and sending mail:
FORM send_mail .
u2022 Define the attachment format
lw_doc_type = 'XLS'.
u2022 Create the document which is to be sent
lwa_doc_chng-obj_name = 'List'.
lwa_doc_chng-obj_descr = w_subject. "Subject
lwa_doc_chng-obj_langu = sy-langu.
u2022 Fill the document data and get size of message
LOOP AT t_message.
lt_objtxt = t_message-line.
APPEND lt_objtxt.
ENDLOOP.
DESCRIBE TABLE lt_objtxt LINES lw_tab_lines.
IF lw_tab_lines GT 0.
READ TABLE lt_objtxt INDEX lw_tab_lines.
lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
lwa_doc_chng-obj_langu = sy-langu.
lwa_doc_chng-sensitivty = 'F'.
ELSE.
lwa_doc_chng-doc_size = 0.
ENDIF.
u2022 Fill Packing List For the body of e-mail
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lw_tab_lines.
lt_packing_list-doc_type = 'RAW'.
APPEND lt_packing_list.
u2022 Create the attachment (the list itself)
DESCRIBE TABLE t_xlstab LINES lw_tab_lines.
u2022 Fill the fields of the packing_list for creating the attachment:
lt_packing_list-transf_bin = 'X'.
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lw_tab_lines.
lt_packing_list-doc_type = lw_doc_type.
lt_packing_list-obj_name = 'Attach'.
lt_packing_list-obj_descr = w_docdesc.
lt_packing_list-doc_size = lw_tab_lines * 255.
APPEND lt_packing_list.
u2022 Fill the mail recipient list
lt_reclist-rec_type = 'U'.
LOOP AT t_recipient_list.
lt_reclist-receiver = t_recipient_list-address.
APPEND lt_reclist.
ENDLOOP.
u2022 Finally send E-Mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = lw_sent_to_all
TABLES
packing_list = lt_packing_list
object_header = lt_objhead
contents_bin = t_xlstab
contents_txt = lt_objtxt
receivers = lt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Hope it will help you
regards
Rahul sharma -
Help--How can I open only one java program at one time?
How can I open only one java program(same program) in Windows at one time?
In Java 1.5, you can use the JVM's own monitoring APIs to examine what other JVMs are running on the system, and what applications they're running.
It's general and powerful, but complex. The socket/file/whatever approach is cleaner, and probably more suited to your usage.
Don't bother trying to use the Windows task manager for this sort of thing. You have to write messy native code, and it isn't reliable after all that anyway. -
How to call Jakarta Ant via JAVA?
Hi.
My application has a new menu. This menu creates a build.xml Ant file.
Now, when this menu is invoked , its action should call
Jakarta Ant, after creating the xml file, so that the build.xml will
do what is necessary.
How can I do it? That is, how to call the Ant via java?
Is there any way to use an Ant object?
Thanks?
Rodrigo Pimenta Carvalho.There is a slight problem in that
PorjectHelper.configureProject is deprecated, but
that is what Main calls...maybe someone else will
complete this thread with an alternative call.The javadoc recommends using the non static method parse() instead. This is available by implementing class ProjectHelperImpl. An alternative to the code above might look like this:
Project ant = new Project();
ProjectHelper helper = new ProjectHelperImpl();
ant.init();
helper.parse(ant, new File("build.xml"));
ant.executeTarget("clean");you might also want to add a logger so you can see the output of events generated by ant. The DefaultLogger class would be used like this. Simply add the code before you call the ant.init().
DefaultLogger log = new DefaultLogger();
log.setErrorPrintStream(System.err);
log.setOutputPrintStream(System.out);
log.setMessageOutputLevel(Project.MSG_INFO);
ant.addBuildListener(log); -
How to uncompress zip files using java program
hai,
please give some sample code to decompress the zip file.
how to uncompress zip files using java program
thanking you
arivarasuhttp://developer.java.sun.com/developer/technicalArticles/Programming/PerfTuning/
Scroll down to 'Compression' -
How To Read RTF file in JAVA? Using iText?
How To Read RTF file in JAVA? Using iText?.....
import java.io.*;
import com.lowagie.text.*;
import com.lowagie.text.rtf.*;
public class RTF3 {
public static void main(String[] args) {
// System.out.println("This example generate a RTF file name Sample.rtf");
// Create Document object
Document myDoc = new Document();
try {
// Create writer to listen document object
// and directs RTF Stream to the file Sample.rtf
RtfWriter2.getInstance(myDoc, new FileOutputStream("Sample.rtf"));
// open the document object
myDoc.open();
// Create a paragraph
Paragraph p = new Paragraph();
p.add("Helloworld in Rtf file..amazing isn't");
// Add the paragraph to document object
myDoc.add(p);
catch(Exception e) {
System.out.println(e);
//close the document
myDoc.close();
Exception in thread "main" java.lang.NoSuchMethodError: com.lowagie.text.Rectangle.width()F
at com.lowagie.text.rtf.document.RtfPageSetting.rectEquals(RtfPageSetting.java:433)
at com.lowagie.text.rtf.document.RtfPageSetting.guessFormat(RtfPageSetting.java:362)
at com.lowagie.text.rtf.document.RtfPageSetting.setPageSize(RtfPageSetting.java:341)
at com.lowagie.text.rtf.RtfWriter2.setPageSize(RtfWriter2.java:248)
at com.lowagie.text.Document.open(Unknown Source)
at view.RTF3.main(RTF3.java:23)
CAN you HELP me?import com.lowagie.text.Document;
import com.lowagie.text.rtf.parser.RtfParser;
import java.io.FileInputStream;
String inputFile = "sample.rtf";
Document document = new Document();
document.open();
RtfParser parser = new RtfParser(null);
parser.convertRtfDocument(new FileInputStream(inputFile), document); -
How to read icloud mails online
I am using icloude mail in my iPhone 4S. How to read icloud mails online.
Meaning the mails I have received at ..@me can I read them online? I have received a whole lot of mails I would like to read and save online in my laptop.
Thanks,
ShanYou can read your mail online by logging into iCloud.com using your laptop and using the mail feature that you find there.
Maybe you are looking for
-
Digital Camcorders for MacBook Pro
Hello and Happy Holidays to all. This is my first post and also my first Mac, thankfully due to my absolute disgust with MS and PC's anymore. My experience this far has been fantastic. I have no idea why I didn't make the switch earlier. One issue th
-
How to read property files?
I have a problem with a small web-app that I try to use on a SAP J2EE server. The app was developed and tested on JBoss and there it was no problem to read the properties file with the following code: URL resource = getClass().getResource("/WEB-INF/m
-
Update Objects on Loan infotype(0040) ...
Hello Friend's, Actually my requirement is to save infotype 0040 in BADI Implementation class. so I've written one function module ZXXX where inside that FM I'm calling HR_INFOTYPE_OPERATION and passing all the values and it's working fine. So I'
-
TS4002 Can't receive emails on updated iMac
I can't get email on my iMac. I have a mobile me account. Won't let me change my incoming mail server, but won't let me proceed with it blank. All troubleshooting pages say to have incoming server set to IMAP.mail.me.com But its greyed out not allow
-
Can not get Fire Fox to register
It says there is a problem,to check my spelling but it is right.