How to find out what type of error it is: Failure sending mail.
How to find out what type of error it is: Failure sending mail.
am 24.12.2007 01:26:55 von Adrian
This is a multi-part message in MIME format.
------=_NextPart_000_0006_01C84599.C6F99F60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi All,
How can I find the reason for such an error: Failure sending mail.
Some Code...
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the above err)
Appreciate any feedback
Thanks,
Joe
------=_NextPart_000_0006_01C84599.C6F99F60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
Hi All,
How can I find the reason for such an =
error:=20
Failure sending mail.
Some Code...
oMailMessage.IsBodyHtml =3D
size=3D2>False
oMailMessage.Body =3D =
cEmailBody
Dim oSMTP As New SmtpClient
color=3D#ff0000>oSMTP.Send(oMailMessage) (in this line I am =
getting=20
the above err)
Appreciate any feedback
Thanks,
Joe
------=_NextPart_000_0006_01C84599.C6F99F60--
Re: How to find out what type of error it is: Failure sending mail.
am 24.12.2007 02:55:13 von smar
This is a multi-part message in MIME format.
------=_NextPart_000_0008_01C845A6.1D4DE130
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Wrap the code in a try...catch block?
"JoeP" wrote in message =
news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for such an error: Failure sending mail.
Some Code...
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the above err)
Appreciate any feedback
Thanks,
Joe
------=_NextPart_000_0008_01C845A6.1D4DE130
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
Wrap the code in a try...catch =
block?
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com>=20
wrote in message
=
href=3D"news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl">news:% 23i4RTOcRIHA.=
3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for such an =
error:=20
Failure sending mail.
Some Code...
oMailMessage.IsBodyHtml =3D
size=3D2>False
oMailMessage.Body =
cEmailBody
Dim oSMTP As New SmtpClient
color=3D#ff0000>oSMTP.Send(oMailMessage) (in this line I =
am getting=20
the above err)
Appreciate any feedback
Thanks,
Joe
size=3D2>
------=_NextPart_000_0008_01C845A6.1D4DE130--
RE: How to find out what type of error it is: Failure sending mail.
am 24.12.2007 04:32:00 von pbromberg
As Scott indicated, you need to learn to wire up your code with exception
handling in order to be able to determine "what went wrong".
So at a minimum:
oMailMessage.IsBodyHtml = False
oMailMessage.Body = cEmailBody
Dim oSMTP As New SmtpClient
Begin Try
oSMTP.Send(oMailMessage) (in this line I am getting the above err)
Catch ex as Exception
System.Diagnostics.Debug.WriteLine(ex.ToString() )
End Try
Sorry, I really haven't used Visual Basic for a very long time (a good thing)
But you get the idea. Put a breakpoint on the Debug.WriteLine statement and
you can examine the exception by hovering your mouse over the "ex" variable.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"JoeP" wrote:
> Hi All,
>
> How can I find the reason for such an error: Failure sending mail.
>
> Some Code...
>
> oMailMessage.IsBodyHtml = False
> oMailMessage.Body = cEmailBody
> Dim oSMTP As New SmtpClient
> oSMTP.Send(oMailMessage) (in this line I am getting the above err)
>
> Appreciate any feedback
>
> Thanks,
>
> Joe
>
>
Re: How to find out what type of error it is: Failure sending mail.
am 24.12.2007 17:04:48 von smar
oMailMessage.IsBodyHtml = False
oMailMessage.Body = cEmailBody
Dim oSMTP As New SmtpClient
Try
oSMTP.Send(oMailMessage) (in this line I am getting the above err)
Catch ex as Exception
System.Diagnostics.Debug.WriteLine(ex.ToString() )
End Try
Re: How to find out what type of error it is: Failure sending mail.
am 25.12.2007 02:07:08 von Adrian
This is a multi-part message in MIME format.
------=_NextPart_000_001C_01C84668.90290690
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Well I had actuallt the code like the below: The debugger poped up and =
just said that the Failure sending mail.=20
and did not provide the reason. But from some reason in my computer =
under Visual Studio 2005, the Alert message did not pop up.=20
Just wondering why? (The debugger did).=20
Thanks,
Joe
Try
some code.....
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the above err)
Catch smtpEx As SmtpException
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a problem in sending the email: {0}');", =
smtpEx.Message.Replace("'", "\'")), True)
Catch generalEx As Exception
ClientScript.RegisterStartupScript(Me.GetType(), "General Problem", =
String.Format("alert('There was a general problem: {0}');", =
generalEx.Message.Replace("'", "\'")), True)
End Try
"Scott M." wrote in message =
news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl...
Wrap the code in a try...catch block?
"JoeP" wrote in message =
news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for such an error: Failure sending mail.
Some Code...
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the above err)
Appreciate any feedback
Thanks,
Joe
------=_NextPart_000_001C_01C84668.90290690
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
Well I had actuallt =
the code=20
like the below: The debugger poped up and just said that the =
Failure=20
sending mail.
and did not provide the reason. But =
from some=20
reason in my computer under Visual Studio 2005, the Alert =
message did=20
not pop up.
Just wondering why? (The debugger =
did).=20
Thanks,
color=3D#000000>Joe
Try
color=3D#000000> =20
some code.....
oMailMessage.IsBodyHtml =3D
color=3D#0000ff size=3D2>False
size=3D2> =20
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New=20
SmtpClient
=20
oSMTP.Send(oMailMessage) (in this line I am getting the =
above=20
err)
size=3D2>
Catch
size=3D2> smtpEx As
size=3D2>=20
SmtpException
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email: =
{0}');"
size=3D2>, smtpEx.Message.Replace(
size=3D2>"'",
size=3D2>"\'")),
size=3D2>True)
Catch =
generalEx=20
As =
Exception
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"General Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"alert('There was a general problem: {0}');"
size=3D2>, generalEx.Message.Replace(
size=3D2>"'",
size=3D2>"\'")),
size=3D2>True)
End =
color=3D#0000ff size=3D2>Try
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> wrote in =
message
href=3D"news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl">news :%23lIk0%23cR=
IHA.4444@TK2MSFTNGP02.phx.gbl...
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Wrap the code in a try...catch=20
block?
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> wrote =
in message=20
=
href=3D"news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl">news:% 23i4RTOcRIHA.=
3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for such =
an error:=20
Failure sending mail.
Some Code...
oMailMessage.IsBodyHtml =3D
size=3D2>False
oMailMessage.Body =
cEmailBody
Dim oSMTP As New =
SmtpClient
color=3D#ff0000>oSMTP.Send(oMailMessage) (in this line I =
am=20
getting the above err)
Appreciate any =
feedback
Thanks,
Joe
size=3D2>
------=_NextPart_000_001C_01C84668.90290690--
Re: How to find out what type of error it is: Failure sending mail.
am 25.12.2007 02:23:39 von Adrian
Thanks,
Re: How to find out what type of error it is: Failure sending mail.
am 25.12.2007 02:47:57 von Adrian
This is a multi-part message in MIME format.
------=_NextPart_000_0022_01C8466E.43F3D7E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi All,
Ok, after checking into it I had some code after the End Try and that =
was the reason Alert() did not pop up.=20
Moving that code under the Try fixed the problem.
But I am trying to break the message into 2 lines:
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a problem in sending the email! Please =
call us by phone {0}');", smtpEx.Message.Replace("'", "\'")), True)
Now how do I bring the actual err line into the second line of the =
Alert()
There was a problem in sending the email! Please call us by phone.=20
Unable to cast object of type 'System.Int32' to type =
'System.Net.Mail.MailMessage'
Thanks,
Joe
"JoeP" wrote in message =
news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl...
Well I had actuallt the code like the below: The debugger poped up and =
just said that the Failure sending mail.=20
and did not provide the reason. But from some reason in my computer =
under Visual Studio 2005, the Alert message did not pop up.=20
Just wondering why? (The debugger did).=20
Thanks,
Joe
Try
some code.....
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the above =
err)
Catch smtpEx As SmtpException
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a problem in sending the email: {0}');", =
smtpEx.Message.Replace("'", "\'")), True)
Catch generalEx As Exception
ClientScript.RegisterStartupScript(Me.GetType(), "General =
Problem", String.Format("alert('There was a general problem: {0}');", =
generalEx.Message.Replace("'", "\'")), True)
End Try
"Scott M." wrote in message =
news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl...
Wrap the code in a try...catch block?
"JoeP" wrote in message =
news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for such an error: Failure sending mail.
Some Code...
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the above =
err)
Appreciate any feedback
Thanks,
Joe
------=_NextPart_000_0022_01C8466E.43F3D7E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
Hi All,
Ok, after checking into it I had some =
code after=20
the End Try
color=3D#000000>and that was the=20
reason Alert() did not pop up.
Moving that code under the Try fixed =
the=20
problem.
But I am trying to break the message =
into 2=20
lines:
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email! Please call =
us by=20
phone {0}');", =
smtpEx.Message.Replace(
color=3D#800000 size=3D2>"'",
color=3D#800000=20
size=3D2>"\'")),
size=3D2>True)
Now how do I bring the actual err =
line into=20
the second line of the Alert()
There was a =
problem in sending=20
the email! Please call us by phone.
Unable to cast object of =
type=20
'System.Int32' to type 'System.Net.Mail.MailMessage'
Thanks,
Joe
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com>=20
wrote in message
=
href=3D"news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl">news:eGe SbJpRIHA.5988=
@TK2MSFTNGP02.phx.gbl...
Well I had actuallt =
the code=20
like the below: The debugger poped up and just said that the =
Failure=20
sending mail.
and did not provide the reason. But =
from some=20
reason in my computer under Visual Studio 2005, the Alert =
message=20
did not pop up.
Just wondering why? (The debugger =
did).=20
Thanks,
color=3D#000000>Joe
Try
color=3D#000000> some =
code.....
=20
oMailMessage.IsBodyHtml =3D
size=3D2>False
size=3D2> oMailMessage.Body =3D =
cEmailBody
Dim oSMTP As New=20
SmtpClient
=20
oSMTP.Send(oMailMessage) (in this line I am getting the =
above=20
err)
size=3D2>
Catch
size=3D2> smtpEx As
size=3D2>=20
SmtpException
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email: =
{0}');"
size=3D2>, smtpEx.Message.Replace(
size=3D2>"'",
size=3D2>"\'")),
size=3D2>True)
Catch =
generalEx=20
As =
Exception
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"General Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"alert('There was a general problem: {0}');"
size=3D2>, generalEx.Message.Replace(
size=3D2>"'",
size=3D2>"\'")),
size=3D2>True)
End =
color=3D#0000ff size=3D2>Try
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> wrote in =
message=20
=
href=3D"news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl">news :%23lIk0%23cR=
IHA.4444@TK2MSFTNGP02.phx.gbl...
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Wrap the code in a try...catch=20
block?
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> =
wrote in=20
message
=
href=3D"news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl">news:% 23i4RTOcRIHA.=
3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for =
such an error:=20
Failure sending mail.
Some Code...
oMailMessage.IsBodyHtml =3D
size=3D2>False
oMailMessage.Body =
cEmailBody
Dim oSMTP As New =
SmtpClient
color=3D#ff0000>oSMTP.Send(oMailMessage) (in this line =
I am=20
getting the above err)
Appreciate any =
feedback
Thanks,
Joe
size=3D2>
<=
/HTML>
------=_NextPart_000_0022_01C8466E.43F3D7E0--
Re: How to find out what type of error it is: Failure sending mail.
am 25.12.2007 03:44:52 von smar
This is a multi-part message in MIME format.
------=_NextPart_000_0028_01C84676.375E20A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
When you are in a Catch section, notice that the exception is passed to =
the catch as "ex". If you check out the properties of "ex", you can =
find out about the exception. Start with this:
Catch ex As Exception
console.writeline("Exception type is: " & ex.getType.toString)
console.writeline("Exception message is: " & ex.Message)
"JoeP" wrote in message =
news:%23XxCPgpRIHA.4476@TK2MSFTNGP06.phx.gbl...
Hi All,
Ok, after checking into it I had some code after the End Try and that =
was the reason Alert() did not pop up.=20
Moving that code under the Try fixed the problem.
But I am trying to break the message into 2 lines:
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a problem in sending the email! Please =
call us by phone {0}');", smtpEx.Message.Replace("'", "\'")), True)
Now how do I bring the actual err line into the second line of the =
Alert()
There was a problem in sending the email! Please call us by phone.=20
Unable to cast object of type 'System.Int32' to type =
'System.Net.Mail.MailMessage'
Thanks,
Joe
"JoeP" wrote in message =
news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl...
Well I had actuallt the code like the below: The debugger poped up =
and just said that the Failure sending mail.=20
and did not provide the reason. But from some reason in my computer =
under Visual Studio 2005, the Alert message did not pop up.=20
Just wondering why? (The debugger did).=20
Thanks,
Joe
Try
some code.....
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the above =
err)
Catch smtpEx As SmtpException
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail =
Problem", String.Format("Alert('There was a problem in sending the =
email: {0}');", smtpEx.Message.Replace("'", "\'")), True)
Catch generalEx As Exception
ClientScript.RegisterStartupScript(Me.GetType(), "General =
Problem", String.Format("alert('There was a general problem: {0}');", =
generalEx.Message.Replace("'", "\'")), True)
End Try
"Scott M." wrote in message =
news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl...
Wrap the code in a try...catch block?
"JoeP" wrote in message =
news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for such an error: Failure sending =
mail.
Some Code...
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the above =
err)
Appreciate any feedback
Thanks,
Joe
------=_NextPart_000_0028_01C84676.375E20A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
When you are in a Catch section, notice =
that the=20
exception is passed to the catch as "ex". If you check out the =
properties=20
of "ex", you can find out about the exception. Start with=20
this:
Catch ex As Exception
=
console.writeline("Exception=20
type is: " & ex.getType.toString)
=20
console.writeline("Exception message is: " & =
ex.Message)
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com>=20
wrote in message
=
href=3D"news:%23XxCPgpRIHA.4476@TK2MSFTNGP06.phx.gbl">news:% 23XxCPgpRIHA.=
4476@TK2MSFTNGP06.phx.gbl...
Hi All,
Ok, after checking into it I had some =
code after=20
the End Try
color=3D#000000>and that was=20
the reason Alert() did not pop up.
Moving that code under the Try fixed =
the=20
problem.
But I am trying to break the message =
into 2=20
lines:
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email! Please call =
us by=20
phone {0}');", =
smtpEx.Message.Replace(
color=3D#800000 size=3D2>"'",
color=3D#800000=20
size=3D2>"\'")),
size=3D2>True)
Now how do I bring the actual err =
line into=20
the second line of the Alert()
There was a =
problem in=20
sending the email! Please call us by phone.
Unable to cast =
object of=20
type 'System.Int32' to type =
'System.Net.Mail.MailMessage'
Thanks,
Joe
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> wrote =
in message=20
=
href=3D"news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl">news:eGe SbJpRIHA.5988=
@TK2MSFTNGP02.phx.gbl...
Well I had actuallt =
the code=20
like the below: The debugger poped up and just said that the=20
Failure sending mail.
and did not provide the reason. =
But from some=20
reason in my computer under Visual Studio 2005, the Alert =
message=20
did not pop up.
Just wondering why? (The debugger =
did).=20
Thanks,
size=3D2>
color=3D#000000>Joe
Try
color=3D#000000> some =
code.....
=20
oMailMessage.IsBodyHtml =3D
size=3D2>False
size=3D2> oMailMessage.Body =3D =
cEmailBody
Dim oSMTP As New =
SmtpClient
=20
oSMTP.Send(oMailMessage) (in this line I am getting the =
above=20
err)
size=3D2>
Catch smtpEx
color=3D#0000ff=20
size=3D2>As SmtpException
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email: =
{0}');"
size=3D2>, smtpEx.Message.Replace(
size=3D2>"'",
size=3D2>"\'")),
size=3D2>True)
Catch =
generalEx=20
As =
Exception
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"General Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"alert('There was a general problem: {0}');"
size=3D2>, generalEx.Message.Replace(
color=3D#800000=20
size=3D2>"'",
size=3D2>"\'")),
size=3D2>True)
End =
color=3D#0000ff size=3D2>Try
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> wrote =
in message=20
=
href=3D"news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl">news :%23lIk0%23cR=
IHA.4444@TK2MSFTNGP02.phx.gbl...
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Wrap the code in a try...catch=20
block?
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> =
wrote in=20
message
=
href=3D"news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl">news:% 23i4RTOcRIHA.=
3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for =
such an=20
error: Failure sending mail.
size=3D2>
Some Code...
oMailMessage.IsBodyHtml =3D
size=3D2>False
oMailMessage.Body =
cEmailBody
Dim oSMTP As New =
SmtpClient
color=3D#ff0000>oSMTP.Send(oMailMessage) (in this =
line I am=20
getting the above err)
Appreciate any =
feedback
Thanks,
Joe
=
size=3D2>
UOTE>
------=_NextPart_000_0028_01C84676.375E20A0--
Re: How to find out what type of error it is: Failure sending mail.
am 25.12.2007 18:42:40 von Adrian
This is a multi-part message in MIME format.
------=_NextPart_000_0014_01C846F3.A3B0F660
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
My question is now how can I concatenate the 2 strings together into the =
message box for the Alert()?
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a problem in sending the email! Please =
call us by phone {0}');", smtpEx.Message.Replace("'", "\'")), True)
String 1 is: 'There was a problem in sending the email! Please call us =
by phone!=20
String 2 is:smtpEx.Message
Thanks.
"Scott M." wrote in message =
news:OAtGO$pRIHA.4180@TK2MSFTNGP06.phx.gbl...
When you are in a Catch section, notice that the exception is passed =
to the catch as "ex". If you check out the properties of "ex", you can =
find out about the exception. Start with this:
Catch ex As Exception
console.writeline("Exception type is: " & ex.getType.toString)
console.writeline("Exception message is: " & ex.Message)
"JoeP" wrote in message =
news:%23XxCPgpRIHA.4476@TK2MSFTNGP06.phx.gbl...
Hi All,
Ok, after checking into it I had some code after the End Try and =
that was the reason Alert() did not pop up.=20
Moving that code under the Try fixed the problem.
But I am trying to break the message into 2 lines:
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a problem in sending the email! Please =
call us by phone {0}');", smtpEx.Message.Replace("'", "\'")), True)
Now how do I bring the actual err line into the second line of the =
Alert()
There was a problem in sending the email! Please call us by phone.=20
Unable to cast object of type 'System.Int32' to type =
'System.Net.Mail.MailMessage'
Thanks,
Joe
"JoeP" wrote in message =
news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl...
Well I had actuallt the code like the below: The debugger poped up =
and just said that the Failure sending mail.=20
and did not provide the reason. But from some reason in my =
computer under Visual Studio 2005, the Alert message did not pop up.=20
Just wondering why? (The debugger did).=20
Thanks,
Joe
Try
some code.....
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the =
above err)
Catch smtpEx As SmtpException
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail =
Problem", String.Format("Alert('There was a problem in sending the =
email: {0}');", smtpEx.Message.Replace("'", "\'")), True)
Catch generalEx As Exception
ClientScript.RegisterStartupScript(Me.GetType(), "General =
Problem", String.Format("alert('There was a general problem: {0}');", =
generalEx.Message.Replace("'", "\'")), True)
End Try
"Scott M." wrote in message =
news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl...
Wrap the code in a try...catch block?
"JoeP" wrote in message =
news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for such an error: Failure sending =
mail.
Some Code...
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the =
above err)
Appreciate any feedback
Thanks,
Joe
------=_NextPart_000_0014_01C846F3.A3B0F660
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
My question is now how can I =
concatenate the 2=20
strings together into the message box for the Alert()?
ClientScript.RegisterStartupScript(
color=3D#0000ff=20
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email! Please call =
us by=20
phone {0}');", =
smtpEx.Message.Replace(
color=3D#800000 size=3D2>"'",
color=3D#800000=20
size=3D2>"\'")),
size=3D2>True)
String 1 is:
color=3D#800000>'There=20
was a problem in sending the email! Please call us by=20
phone!
String 2 is:
color=3D#000000>smtpEx.Message
Thanks.
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> wrote in =
message
href=3D"news:OAtGO$pRIHA.4180@TK2MSFTNGP06.phx.gbl">news:OAt GO$pRIHA.4180=
@TK2MSFTNGP06.phx.gbl...
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
When you are in a Catch section, =
notice that the=20
exception is passed to the catch as "ex". If you check out the=20
properties of "ex", you can find out about the exception. Start =
with=20
this:
Catch ex As Exception
=
console.writeline("Exception=20
type is: " & ex.getType.toString)
=20
console.writeline("Exception message is: " & =
ex.Message)
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> wrote =
in message=20
=
href=3D"news:%23XxCPgpRIHA.4476@TK2MSFTNGP06.phx.gbl">news:% 23XxCPgpRIHA.=
4476@TK2MSFTNGP06.phx.gbl...
Hi All,
Ok, after checking into it I had =
some code=20
after the End Try
color=3D#000000>and that was the reason Alert() did not pop up. =
Moving that code under the Try =
fixed the=20
problem.
But I am trying to break the =
message into 2=20
lines:
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email! Please =
call us by=20
phone {0}');", =
smtpEx.Message.Replace(
color=3D#800000 size=3D2>"'",
color=3D#800000=20
size=3D2>"\'")),
size=3D2>True)
Now how do I bring the actual err=20
line into the second line of the Alert()
There was a =
problem in=20
sending the email! Please call us by phone.
Unable to cast =
object=20
of type 'System.Int32' to type=20
'System.Net.Mail.MailMessage'
Thanks,
Joe
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> =
wrote in=20
message
=
href=3D"news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl">news:eGe SbJpRIHA.5988=
@TK2MSFTNGP02.phx.gbl...
Well I had actuallt =
the code=20
like the below: The debugger poped up and just said that the=20
Failure sending mail.
and did not provide the reason. =
But from=20
some reason in my computer under Visual Studio 2005, the =
Alert=20
message did not pop up.
Just wondering why? (The =
debugger did).=20
Thanks,
size=3D2>
color=3D#000000>Joe
Try
color=3D#000000> some =
code.....
=20
oMailMessage.IsBodyHtml =3D
size=3D2>False
size=3D2> oMailMessage.Body =3D =
cEmailBody
Dim oSMTP As =
New=20
SmtpClient
=20
oSMTP.Send(oMailMessage) (in this line I am getting =
the above=20
err)
size=3D2>
Catch smtpEx
color=3D#0000ff=20
size=3D2>As SmtpException
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email:=20
{0}');", smtpEx.Message.Replace(
color=3D#800000 size=3D2>"'",
color=3D#800000=20
size=3D2>"\'")),
color=3D#0000ff=20
size=3D2>True)
Catch
size=3D2> generalEx=20
As =
Exception
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"General Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"alert('There was a general problem: {0}');"
size=3D2>, generalEx.Message.Replace(
color=3D#800000=20
size=3D2>"'",
size=3D2>"\'")),
color=3D#0000ff=20
size=3D2>True)
End =
color=3D#0000ff size=3D2>Try
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> =
wrote in=20
message
=
href=3D"news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl">news :%23lIk0%23cR=
IHA.4444@TK2MSFTNGP02.phx.gbl...
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Wrap the code in a try...catch=20
block?
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> =
wrote in=20
message
=
href=3D"news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl">news:% 23i4RTOcRIHA.=
3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for =
such an=20
error: Failure sending mail.
size=3D2>
Some Code...
oMailMessage.IsBodyHtml =3D
size=3D2>False
oMailMessage.Body =
cEmailBody
Dim oSMTP As New =
SmtpClient
color=3D#ff0000>oSMTP.Send(oMailMessage) (in this =
line I am=20
getting the above err)
Appreciate any =
feedback
Thanks,
Joe
=
size=3D2>
UOTE>
------=_NextPart_000_0014_01C846F3.A3B0F660--
Re: How to find out what type of error it is: Failure sending mail.
am 26.12.2007 04:01:03 von smar
This is a multi-part message in MIME format.
------=_NextPart_000_000C_01C84741.A46E0860
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Generally, you don't want to take information from the exception and =
send it directly to the client as this can expose security holes & =
proprietary code. Instead you find out what exception you have =
encountered in the Try...Catch and then you write whatever you find to =
be appropriate to the client based on that information. If you really =
want to include exception information directly in your output, it is a =
simple matter of concatenation:
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a {0} problem in sending the email! =
Please call us by phone {1}');", ex.GetType.ToString(), =
smtpEx.Message.Replace("'", "\'")), True)
"JoeP" wrote in message =
news:eLETt1xRIHA.4180@TK2MSFTNGP06.phx.gbl...
My question is now how can I concatenate the 2 strings together into =
the message box for the Alert()?
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a problem in sending the email! Please =
call us by phone {0}');", smtpEx.Message.Replace("'", "\'")), True)
String 1 is: 'There was a problem in sending the email! Please call us =
by phone!=20
String 2 is:smtpEx.Message
Thanks.
"Scott M." wrote in message =
news:OAtGO$pRIHA.4180@TK2MSFTNGP06.phx.gbl...
When you are in a Catch section, notice that the exception is passed =
to the catch as "ex". If you check out the properties of "ex", you can =
find out about the exception. Start with this:
Catch ex As Exception
console.writeline("Exception type is: " & ex.getType.toString)
console.writeline("Exception message is: " & ex.Message)
"JoeP" wrote in message =
news:%23XxCPgpRIHA.4476@TK2MSFTNGP06.phx.gbl...
Hi All,
Ok, after checking into it I had some code after the End Try and =
that was the reason Alert() did not pop up.=20
Moving that code under the Try fixed the problem.
But I am trying to break the message into 2 lines:
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a problem in sending the email! Please =
call us by phone {0}');", smtpEx.Message.Replace("'", "\'")), True)
Now how do I bring the actual err line into the second line of the =
Alert()
There was a problem in sending the email! Please call us by phone. =
Unable to cast object of type 'System.Int32' to type =
'System.Net.Mail.MailMessage'
Thanks,
Joe
"JoeP" wrote in message =
news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl...
Well I had actuallt the code like the below: The debugger poped =
up and just said that the Failure sending mail.=20
and did not provide the reason. But from some reason in my =
computer under Visual Studio 2005, the Alert message did not pop up.=20
Just wondering why? (The debugger did).=20
Thanks,
Joe
Try
some code.....
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the =
above err)
Catch smtpEx As SmtpException
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail =
Problem", String.Format("Alert('There was a problem in sending the =
email: {0}');", smtpEx.Message.Replace("'", "\'")), True)
Catch generalEx As Exception
ClientScript.RegisterStartupScript(Me.GetType(), "General =
Problem", String.Format("alert('There was a general problem: {0}');", =
generalEx.Message.Replace("'", "\'")), True)
End Try
"Scott M." wrote in message =
news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl...
Wrap the code in a try...catch block?
"JoeP" wrote in message =
news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for such an error: Failure sending =
mail.
Some Code...
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the =
above err)
Appreciate any feedback
Thanks,
Joe
------=_NextPart_000_000C_01C84741.A46E0860
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
Generally, you don't want to take =
information from=20
the exception and send it directly to the client as this can expose =
security=20
holes & proprietary code. Instead you find out what exception =
you have=20
encountered in the Try...Catch and then you write whatever you find to =
be=20
appropriate to the client based on that information. If you really =
want to=20
include exception information directly in your output, it is a simple =
matter of=20
concatenation:
ClientScript.RegisterStartupScript(
color=3D#0000ff=20
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a {0} problem in sending the email! =
Please call us=20
by phone {1}');",=20
ex.GetType.ToString(), smtpEx.Message.Replace(
color=3D#800000=20
size=3D2>"'",
size=3D2>"\'")),
size=3D2>True)
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com>=20
wrote in message
=
href=3D"news:eLETt1xRIHA.4180@TK2MSFTNGP06.phx.gbl">news:eLE Tt1xRIHA.4180=
@TK2MSFTNGP06.phx.gbl...
My question is now how can I =
concatenate the=20
2 strings together into the message box for the Alert()?
ClientScript.RegisterStartupScript(
color=3D#0000ff=20
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email! Please call =
us by=20
phone {0}');", =
smtpEx.Message.Replace(
color=3D#800000 size=3D2>"'",
color=3D#800000=20
size=3D2>"\'")),
size=3D2>True)
String 1 is:
color=3D#800000>'There was a problem in sending the email! Please call =
us by=20
phone!
String 2 =
is:
color=3D#000000>smtpEx.Message
Thanks.
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> wrote in =
message=20
=
href=3D"news:OAtGO$pRIHA.4180@TK2MSFTNGP06.phx.gbl">news:OAt GO$pRIHA.4180=
@TK2MSFTNGP06.phx.gbl...
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
When you are in a Catch section, =
notice that=20
the exception is passed to the catch as "ex". If you check out =
the=20
properties of "ex", you can find out about the exception. =
Start with=20
this:
Catch ex As Exception
=
console.writeline("Exception=20
type is: " & ex.getType.toString)
=20
console.writeline("Exception message is: " &=20
ex.Message)
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> =
wrote in=20
message
=
href=3D"news:%23XxCPgpRIHA.4476@TK2MSFTNGP06.phx.gbl">news:% 23XxCPgpRIHA.=
4476@TK2MSFTNGP06.phx.gbl...
Hi All,
Ok, after checking into it I had =
some code=20
after the End Try
color=3D#000000>and that was the reason Alert() did not pop =
up.=20
Moving that code under the Try =
fixed the=20
problem.
But I am trying to break the =
message into 2=20
lines:
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email! Please =
call us by=20
phone {0}');",=20
smtpEx.Message.Replace(
size=3D2>"'"
size=3D2>, "\'"
size=3D2>)),=20
True
size=3D2>)
Now how do I bring the actual err =
line into the second line of the Alert()
There was a =
problem in=20
sending the email! Please call us by phone.
Unable to =
cast object=20
of type 'System.Int32' to type=20
'System.Net.Mail.MailMessage'
Thanks,
Joe
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> =
wrote in=20
message
=
href=3D"news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl">news:eGe SbJpRIHA.5988=
@TK2MSFTNGP02.phx.gbl...
Well I had actuallt =
the code=20
like the below: The debugger poped up and just said that =
the=20
Failure sending mail.
and did not provide the =
reason. But from=20
some reason in my computer under Visual Studio =
2005, the Alert=20
message did not pop up.
Just wondering why? (The =
debugger did).=20
Thanks,
size=3D2>
color=3D#000000>Joe
Try
color=3D#000000> some =
code.....
=20
oMailMessage.IsBodyHtml =3D
size=3D2>False
=
oMailMessage.Body=20
=3D cEmailBody
Dim oSMTP As =
New=20
SmtpClient
=20
oSMTP.Send(oMailMessage) (in this line I am getting =
the=20
above err)
size=3D2>
Catch smtpEx
color=3D#0000ff=20
size=3D2>As SmtpException
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email:=20
{0}');", =
smtpEx.Message.Replace(
color=3D#800000 size=3D2>"'",
color=3D#800000=20
size=3D2>"\'")),
color=3D#0000ff=20
size=3D2>True)
Catch
size=3D2> generalEx=20
As =
Exception
=20
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"General Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"alert('There was a general problem: =
{0}');"
size=3D2>, generalEx.Message.Replace(
color=3D#800000=20
size=3D2>"'",
size=3D2>"\'")),
color=3D#0000ff=20
size=3D2>True)
End
size=3D2>=20
size=3D2>Try
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> =
wrote in=20
message
=
href=3D"news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl">news :%23lIk0%23cR=
IHA.4444@TK2MSFTNGP02.phx.gbl...
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Wrap the code in a =
try...catch=20
block?
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
=
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> wrote in=20
message
=
href=3D"news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl">news:% 23i4RTOcRIHA.=
3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason =
for such an=20
error: Failure sending mail.
size=3D2>
Some Code...
oMailMessage.IsBodyHtml =3D
color=3D#0000ff=20
size=3D2>False
oMailMessage.Body =
=
cEmailBody
Dim oSMTP As New =
SmtpClient
color=3D#ff0000>oSMTP.Send(oMailMessage) (in =
this line I=20
am getting the above err)
Appreciate any =
feedback
Thanks,
Joe
=
size=3D2>
UOTE>
------=_NextPart_000_000C_01C84741.A46E0860--
Re: How to find out what type of error it is: Failure sending mail.
am 26.12.2007 15:49:37 von Adrian
This is a multi-part message in MIME format.
------=_NextPart_000_000A_01C847A4.A104BCB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Ok Thanks
"Scott M." wrote in message =
news:uk0K6s2RIHA.4400@TK2MSFTNGP06.phx.gbl...
Generally, you don't want to take information from the exception and =
send it directly to the client as this can expose security holes & =
proprietary code. Instead you find out what exception you have =
encountered in the Try...Catch and then you write whatever you find to =
be appropriate to the client based on that information. If you really =
want to include exception information directly in your output, it is a =
simple matter of concatenation:
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a {0} problem in sending the email! =
Please call us by phone {1}');", ex.GetType.ToString(), =
smtpEx.Message.Replace("'", "\'")), True)
"JoeP" wrote in message =
news:eLETt1xRIHA.4180@TK2MSFTNGP06.phx.gbl...
My question is now how can I concatenate the 2 strings together into =
the message box for the Alert()?
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail Problem", =
String.Format("Alert('There was a problem in sending the email! Please =
call us by phone {0}');", smtpEx.Message.Replace("'", "\'")), True)
String 1 is: 'There was a problem in sending the email! Please call =
us by phone!=20
String 2 is:smtpEx.Message
Thanks.
"Scott M." wrote in message =
news:OAtGO$pRIHA.4180@TK2MSFTNGP06.phx.gbl...
When you are in a Catch section, notice that the exception is =
passed to the catch as "ex". If you check out the properties of "ex", =
you can find out about the exception. Start with this:
Catch ex As Exception
console.writeline("Exception type is: " & ex.getType.toString)
console.writeline("Exception message is: " & ex.Message)
"JoeP" wrote in message =
news:%23XxCPgpRIHA.4476@TK2MSFTNGP06.phx.gbl...
Hi All,
Ok, after checking into it I had some code after the End Try and =
that was the reason Alert() did not pop up.=20
Moving that code under the Try fixed the problem.
But I am trying to break the message into 2 lines:
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail =
Problem", String.Format("Alert('There was a problem in sending the =
email! Please call us by phone {0}');", smtpEx.Message.Replace("'", =
"\'")), True)
Now how do I bring the actual err line into the second line of =
the Alert()
There was a problem in sending the email! Please call us by =
phone.=20
Unable to cast object of type 'System.Int32' to type =
'System.Net.Mail.MailMessage'
Thanks,
Joe
"JoeP" wrote in message =
news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl...
Well I had actuallt the code like the below: The debugger =
poped up and just said that the Failure sending mail.=20
and did not provide the reason. But from some reason in my =
computer under Visual Studio 2005, the Alert message did not pop up.=20
Just wondering why? (The debugger did).=20
Thanks,
Joe
Try
some code.....
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the =
above err)
Catch smtpEx As SmtpException
ClientScript.RegisterStartupScript(Me.GetType(), "E-Mail =
Problem", String.Format("Alert('There was a problem in sending the =
email: {0}');", smtpEx.Message.Replace("'", "\'")), True)
Catch generalEx As Exception
ClientScript.RegisterStartupScript(Me.GetType(), "General =
Problem", String.Format("alert('There was a general problem: {0}');", =
generalEx.Message.Replace("'", "\'")), True)
End Try
"Scott M." wrote in message =
news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl...
Wrap the code in a try...catch block?
"JoeP" wrote in message =
news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason for such an error: Failure =
sending mail.
Some Code...
oMailMessage.IsBodyHtml =3D False
oMailMessage.Body =3D cEmailBody
Dim oSMTP As New SmtpClient
oSMTP.Send(oMailMessage) (in this line I am getting the =
above err)
Appreciate any feedback
Thanks,
Joe
------=_NextPart_000_000A_01C847A4.A104BCB0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
Ok Thanks
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> wrote in =
message=20
=
href=3D"news:uk0K6s2RIHA.4400@TK2MSFTNGP06.phx.gbl">news:uk0 K6s2RIHA.4400=
@TK2MSFTNGP06.phx.gbl...
Generally, you don't want to take =
information=20
from the exception and send it directly to the client as this can =
expose=20
security holes & proprietary code. Instead you find out what =
exception you have encountered in the Try...Catch and then you write =
whatever=20
you find to be appropriate to the client based on that =
information. If=20
you really want to include exception information directly in your =
output, it=20
is a simple matter of concatenation:
ClientScript.RegisterStartupScript(
color=3D#0000ff=20
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a {0} problem in sending the email! =
Please call=20
us by phone {1}');",=20
ex.GetType.ToString(), smtpEx.Message.Replace(
color=3D#800000=20
size=3D2>"'",
size=3D2>"\'")),
size=3D2>True)
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> wrote =
in message=20
=
href=3D"news:eLETt1xRIHA.4180@TK2MSFTNGP06.phx.gbl">news:eLE Tt1xRIHA.4180=
@TK2MSFTNGP06.phx.gbl...
My question is now how can I =
concatenate=20
the 2 strings together into the message box for the =
Alert()?
ClientScript.RegisterStartupScript(
color=3D#0000ff=20
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email! Please =
call us by=20
phone {0}');", =
smtpEx.Message.Replace(
color=3D#800000 size=3D2>"'",
color=3D#800000=20
size=3D2>"\'")),
size=3D2>True
size=3D2>)
String 1 is:
color=3D#800000>'There was a problem in sending the email! Please =
call us by=20
phone!
String 2 =
is:
color=3D#000000>smtpEx.Message
Thanks.
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> wrote =
in message=20
=
href=3D"news:OAtGO$pRIHA.4180@TK2MSFTNGP06.phx.gbl">news:OAt GO$pRIHA.4180=
@TK2MSFTNGP06.phx.gbl...
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
When you are in a Catch section, =
notice that=20
the exception is passed to the catch as "ex". If you check =
out the=20
properties of "ex", you can find out about the exception. =
Start with=20
this:
Catch ex As =
Exception
=20
console.writeline("Exception type is: " &=20
ex.getType.toString)
=20
console.writeline("Exception message is: " &=20
ex.Message)
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> =
wrote in=20
message
=
href=3D"news:%23XxCPgpRIHA.4476@TK2MSFTNGP06.phx.gbl">news:% 23XxCPgpRIHA.=
4476@TK2MSFTNGP06.phx.gbl...
Hi All,
Ok, after checking into it I =
had some code=20
after the End Try
color=3D#000000>and that was the reason Alert() did not pop =
up.=20
Moving that code under the Try =
fixed the=20
problem.
But I am trying to break the =
message into 2=20
lines:
ClientScript.RegisterStartupScript(
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff=20
size=3D2>String.Format(
color=3D#800000=20
size=3D2>"Alert('There was a problem in sending the email! =
Please call us=20
by phone {0}');",=20
smtpEx.Message.Replace(
size=3D2>"'"
size=3D2>,
size=3D2>"\'")),=20
True
size=3D2>)
Now how do I bring the actual =
err=20
line into the second line of the Alert()
There was =
a problem in=20
sending the email! Please call us by phone.
Unable to =
cast=20
object of type 'System.Int32' to type=20
'System.Net.Mail.MailMessage'
Thanks,
Joe
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> =
wrote in=20
message
=
href=3D"news:eGeSbJpRIHA.5988@TK2MSFTNGP02.phx.gbl">news:eGe SbJpRIHA.5988=
@TK2MSFTNGP02.phx.gbl...
Well I had actuallt =
the code=20
like the below: The debugger poped up and just said that =
the=20
Failure sending mail.
and did not provide the =
reason. But=20
from some reason in my computer under Visual Studio=20
2005, the Alert message did not pop up.
Just wondering why? (The =
debugger did).=20
Thanks,
size=3D2>
color=3D#000000>Joe
Try
color=3D#000000> some =
code.....
=20
oMailMessage.IsBodyHtml =3D
size=3D2>False
=20
oMailMessage.Body =3D cEmailBody
Dim oSMTP =
As New=20
SmtpClient
=20
oSMTP.Send(oMailMessage) (in this line I am =
getting the=20
above err)
size=3D2>
Catch smtpEx
color=3D#0000ff=20
size=3D2>As SmtpException
=20
ClientScript.RegisterStartupScript(
color=3D#0000ff=20
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"E-Mail Problem",
color=3D#0000ff size=3D2>String
size=3D2>.Format(
color=3D#800000 size=3D2>"Alert('There was a problem in =
sending the email:=20
{0}');", =
smtpEx.Message.Replace(
color=3D#800000 size=3D2>"'", =
color=3D#800000 size=3D2>"\'")), =
color=3D#0000ff size=3D2>True)
Catch
size=3D2>=20
generalEx As
size=3D2>=20
Exception
=20
ClientScript.RegisterStartupScript(
color=3D#0000ff=20
size=3D2>Me.GetType(),
color=3D#800000=20
size=3D2>"General Problem",
color=3D#0000ff size=3D2>String
size=3D2>.Format(
color=3D#800000 size=3D2>"alert('There was a general problem:=20
{0}');"
size=3D2>, generalEx.Message.Replace(
color=3D#800000=20
size=3D2>"'",
color=3D#800000=20
size=3D2>"\'")),
color=3D#0000ff=20
size=3D2>True)
End
size=3D2>=20
size=3D2>Try
"Scott M." <
href=3D"mailto:smar@nospam.nospam">smar@nospam.nospam> =
wrote in=20
message
=
href=3D"news:%23lIk0%23cRIHA.4444@TK2MSFTNGP02.phx.gbl">news :%23lIk0%23cR=
IHA.4444@TK2MSFTNGP02.phx.gbl...
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Wrap the code in a =
try...catch=20
block?
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: =
5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"JoeP" <
=
href=3D"mailto:NoSpam@Hotmail.com">NoSpam@Hotmail.com> wrote=20
in message
=
href=3D"news:%23i4RTOcRIHA.3516@TK2MSFTNGP02.phx.gbl">news:% 23i4RTOcRIHA.=
3516@TK2MSFTNGP02.phx.gbl...
Hi All,
How can I find the reason =
for such an=20
error: Failure sending mail.
size=3D2>
Some Code...
oMailMessage.IsBodyHtml =3D
color=3D#0000ff=20
size=3D2>False
oMailMessage.Body =
=
cEmailBody
Dim oSMTP As New =
SmtpClient
color=3D#ff0000>oSMTP.Send(oMailMessage) (in =
this line I=20
am getting the above err)
Appreciate any =
feedback
Thanks,
Joe
=
size=3D2>
UOTE>
------=_NextPart_000_000A_01C847A4.A104BCB0--