email

J

Jaez

I am new to asp.net 2 and am struggling with emailing to a list of
addresses

I can send emails OK using:

Dim MailObj As New System.Net.Mail.SmtpClient
MailObj.Send(EmFrom.Text, EmTo.Text, EmSubj.Text, EmMsg.Text)

but I seem to be unable to detect if an email fails to send ie if the
address has a typo or the address is not able to receive an email

in php I might write something like:

if (mail($to, $subject, $body)) { echo("<p>Message successfully
sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); }

so is thier an equivalent structure in asp.net 2

Thanks

jaez
 
B

Bruno Alexandre

all you have to do is you try/catch

try
Dim MailObj As New System.Net.Mail.SmtpClient
MailObj.Send(EmFrom.Text, EmTo.Text, EmSubj.Text, EmMsg.Text)
Catch ex as Exception
response.write("<p>Message delivery failed...</p>")
response.flush()
End Catch

and please... dont mention PHP! that it's not even a programing language !
it's a scripting language live Javascript is...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top