| | |
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 |
911 actionlistener addressbook android api append applet application array arrays automation binary bluetooth character chat class classes client code component consumer csv database desktop draw eclipse error event exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie objects online oracle oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion robot rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time tree ubuntu windows working





