| | |
Mail User Agent
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Oct 2007
Posts: 9
Reputation:
Solved Threads: 0
For a computer networking course I was given a project to make a Mail User Agent. We were given a few completed classes, but one of them is giving an error. Here is the part of code in question:
The error is that it cannot find symbol "envelope in the second try block. Does the scope of try catch not extend outside? Any suggestions on how to go about fixing this?
Java Syntax (Toggle Plain Text)
try { Envelope envelope = new Envelope(mailMessage, serverField.getText()); } catch (UnknownHostException e) { /* If there is an error, do not go further */ return; } try { SMTPConnection connection = new SMTPConnection(envelope); connection.send(envelope); connection.close(); } catch (IOException error) { System.out.println("Sending failed: " + error); return; } System.out.println("Mail sent succesfully!");
The error is that it cannot find symbol "envelope in the second try block. Does the scope of try catch not extend outside? Any suggestions on how to go about fixing this?
•
•
Join Date: Oct 2009
Posts: 18
Reputation:
Solved Threads: 3
0
#2 Nov 4th, 2009
•
•
•
•
For a computer networking course I was given a project to make a Mail User Agent. We were given a few completed classes, but one of them is giving an error. Here is the part of code in question:
Java Syntax (Toggle Plain Text)
try { Envelope envelope = new Envelope(mailMessage, serverField.getText()); } catch (UnknownHostException e) { /* If there is an error, do not go further */ return; } try { SMTPConnection connection = new SMTPConnection(envelope); connection.send(envelope); connection.close(); } catch (IOException error) { System.out.println("Sending failed: " + error); return; } System.out.println("Mail sent succesfully!");
The error is that it cannot find symbol "envelope in the second try block. Does the scope of try catch not extend outside? Any suggestions on how to go about fixing this?
envelope is declared inside the first Try block so its scope finish there.
If you wish to use envelope in the second try block. Declare outside the try block.
Java Syntax (Toggle Plain Text)
Envelope envelope=null; try { envelope = new Envelope(mailMessage, serverField.getText()); } catch (UnknownHostException e) { /* If there is an error, do not go further */ return; } try { SMTPConnection connection = new SMTPConnection(envelope); connection.send(envelope); connection.close(); } catch (IOException error) { System.out.println("Sending failed: " + error); return; } System.out.println("Mail sent succesfully!");
![]() |
Similar Threads
- trojans wont let me connect to internet (Viruses, Spyware and other Nasties)
- PHP Mail with Sender ID (PHP)
- denying a specific user-agent (Linux Servers and Apache)
- Restoring sbs 2003 mail/user accounts (Networking Hardware Configuration)
- HijackThis error? (Viruses, Spyware and other Nasties)
- help with hjt and vx2/urllogic (Viruses, Spyware and other Nasties)
- help with hjt and vx2/urllogic (split from http://www.daniweb.com/techtalkforums/showthread.php?t=18540&page=1&pp=15) (Viruses, Spyware and other Nasties)
- GET! GOT! GOTCHA! I still don't Get it... (C++)
- 213.159.117.130 trojan.. help!! (Viruses, Spyware and other Nasties)
- Yahoo mail goes 100MB (Geeks' Lounge)
Other Threads in the Java Forum
- Previous Thread: How to change application design? (custom jFrame, buttons)
- Next Thread: How to add QMainWindow
| Thread Tools | Search this Thread |
Tag cloud for Java
account addressbook android api apple applet application arguments array arrays automation binary bluetooth calculator character chat class classes client code columns component css data database developmenthelp draw eclipse error errors event exception fractal functiontesting game givemetehcodez google graphics gridlayout gui html ide idea image infinite input integer j2me java javaprojects jme jmf jni jpanel julia linux list loan loop map method methods midlethttpconnection mobile monitoring netbeans newbie number oracle pearl print problem program programming project property radio recursion scanner screen search server set size sms socket software sort splash sql static storm string support swing test threads time tree windows





