473,412 Members | 5,385 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Try / Catch

Hello,

I am sending an e-mail and I need to call a function the following way:

1. Display("OK") if Email was SENT
2. Display("Error") if Email was NOT SENT

I have this code block:

Try
SmtpMail.Send(email)
Catch ex As Exception
Display("Error")
End Try

My problem is where to place Display("OK") which will only be called if
no exception is Catched, i.e., if the email was sent.

How can I do this?

Thanks,
Miguel

Nov 19 '05 #1
4 1253
Hi ,

Try
SmtpMail.Send(email)
Display("OK")
Catch ex As Exception
Display("Error")
End Try

Best regards....

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com>, haber iletisinde sunlari
yazdi:OM*************@tk2msftngp13.phx.gbl...
Hello,

I am sending an e-mail and I need to call a function the following way:

1. Display("OK") if Email was SENT
2. Display("Error") if Email was NOT SENT

I have this code block:

Try
SmtpMail.Send(email)
Catch ex As Exception
Display("Error")
End Try

My problem is where to place Display("OK") which will only be called if no
exception is Catched, i.e., if the email was sent.

How can I do this?

Thanks,
Miguel

Nov 19 '05 #2
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:OM*************@tk2msftngp13.phx.gbl...
[snip]
Try
SmtpMail.Send(email)
Catch ex As Exception
Display("Error")
End Try

My problem is where to place Display("OK") which will only be called if no
exception is Catched, i.e., if the email was sent.

[snip]

Try
SmtpMail.Send(email)
Display("OK") // RIGHT HERE ****
Catch ex As Exception
Display("Error")
End Try
Nov 19 '05 #3
Try
SmtpMail.Send(email)
Display("Ok")
Catch ex As Exception
Display("Error")
End Try

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:OM*************@tk2msftngp13.phx.gbl...
Hello,

I am sending an e-mail and I need to call a function the following way:

1. Display("OK") if Email was SENT
2. Display("Error") if Email was NOT SENT

I have this code block:

Try
SmtpMail.Send(email)
Catch ex As Exception
Display("Error")
End Try

My problem is where to place Display("OK") which will only be called if no
exception is Catched, i.e., if the email was sent.

How can I do this?

Thanks,
Miguel

Nov 19 '05 #4
Thanks to everybody for your help.

Miguel

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:uE*************@TK2MSFTNGP15.phx.gbl:
Try
SmtpMail.Send(email)
Display("Ok")
Catch ex As Exception
Display("Error")
End Try

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:OM*************@tk2msftngp13.phx.gbl...
Hello,

I am sending an e-mail and I need to call a function the following way:

1. Display("OK") if Email was SENT
2. Display("Error") if Email was NOT SENT

I have this code block:

Try
SmtpMail.Send(email)
Catch ex As Exception
Display("Error")
End Try

My problem is where to place Display("OK") which will only be called if no
exception is Catched, i.e., if the email was sent.

How can I do this?

Thanks,
Miguel


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Gary.Hu | last post by:
I was trying to catch the Arithmetic exception, unsuccessfully. try{ int a = 0, b = 9; b = b / a; }catch(...){ cout << "arithmetic exception was catched!" << endl; } After ran the program,...
11
by: kaeli | last post by:
Hey all, I'd like to start using the try/catch construct in some scripts. Older browsers don't support this. What's the best way to test for support for this construct so it doesn't kill...
4
by: Abhishek Srivastava | last post by:
Hello All, I have seen code snippets like try { ..... } catch {
11
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
13
by: Benny | last post by:
Hi, I have something like this: try { // some code } catch // note - i am catching everything now {
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
23
by: pigeonrandle | last post by:
Hi, Does this bit of code represent complete overkill?! try { //create a treenode TreeNode tn = new TreeNode(); //add it to a treeview tv.Nodes.Add(tn);
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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 project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.