Thursday, March 22, 2012

SmtpMail.Send Error

I am getting the following error when trying to send the
mail object:
COMException (0x80040213): The transport failed to connect
to the server.
]

[TargetInvocationException: Exception has been thrown by
the target of an invocation.]
System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args,
Boolean[] byrefModifiers, Int32 culture, String[]
namedParameters) +0
System.RuntimeType.InvokeMember(String name,
BindingFlags invokeAttr, Binder binder, Object target,
Object[] args, ParameterModifier[] modifiers, CultureInfo
culture, String[] namedParameters) +473
System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject
obj, String methodName, Object[] args) +58

[HttpException (0x80004005): Could not
access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject
obj, String methodName, Object[] args) +113
System.Web.Mail.CdoSysHelper.Send(MailMessage message)
+1512
System.Web.Mail.SmtpMail.Send(MailMessage message) +49
Forms.AddStore.Page_Error(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\Forms\AddStore.aspx.vb:137
System.Web.UI.TemplateControl.OnError(EventArgs e) +109
System.Web.UI.Page.HandleError(Exception e) +68
System.Web.UI.Page.ProcessRequestMain() +2065
System.Web.UI.Page.ProcessRequest() +118
System.Web.UI.Page.ProcessRequest(HttpContext context)
+18
System.Web.CallHandlerExecutionStep.Execute() +179
System.Web.HttpApplication.ExecuteStep(IExecutionS tep
step, Boolean& completedSynchronously) +87

Here is the code I am using:
Dim objMail As New Mail.MailMessage()
Dim objSmtp As Mail.SmtpMail
Dim ErrorMessage As String = "The following errors
occurred: " & ControlChars.CrLf & ex.ToString
objMail.To = "you@dotnet.itags.org.home.com"
objMail.From = "me@dotnet.itags.org.work.com"
objMail.Priority = MailPriority.High
objMail.BodyFormat = MailFormat.Text
objMail.Subject = "Error On AddStore.aspx Page"
objMail.Body = ErrorMessage
objSmtp.SmtpServer = "localhost"
objSmtp.Send(objMail)
objMail = Nothing
objSmtp = Nothing

The only thing I changed in this posting was the email
addresses.
I have also tried not setting the SmtpServer property to
let it use the default.
Not sure what is wrong since I had it working before.

ThanksI don't know what I did but it is working again.
Wierd.
>--Original Message--
>I am getting the following error when trying to send the
>mail object:
>COMException (0x80040213): The transport failed to
connect
>to the server.
>]
>[TargetInvocationException: Exception has been thrown by
>the target of an invocation.]
> System.RuntimeType.InvokeDispMethod(String name,
>BindingFlags invokeAttr, Object target, Object[] args,
>Boolean[] byrefModifiers, Int32 culture, String[]
>namedParameters) +0
> System.RuntimeType.InvokeMember(String name,
>BindingFlags invokeAttr, Binder binder, Object target,
>Object[] args, ParameterModifier[] modifiers, CultureInfo
>culture, String[] namedParameters) +473
> System.Web.Mail.LateBoundAccessHelper.CallMethod
(Object
>obj, String methodName, Object[] args) +58
>[HttpException (0x80004005): Could not
>access 'CDO.Message' object.]
> System.Web.Mail.LateBoundAccessHelper.CallMethod
(Object
>obj, String methodName, Object[] args) +113
> System.Web.Mail.CdoSysHelper.Send(MailMessage message)
>+1512
> System.Web.Mail.SmtpMail.Send(MailMessage message) +49
> Forms.AddStore.Page_Error(Object sender, EventArgs e)
>in C:\Inetpub\wwwroot\Forms\AddStore.aspx.vb:137
> System.Web.UI.TemplateControl.OnError(EventArgs e) +109
> System.Web.UI.Page.HandleError(Exception e) +68
> System.Web.UI.Page.ProcessRequestMain() +2065
> System.Web.UI.Page.ProcessRequest() +118
> System.Web.UI.Page.ProcessRequest(HttpContext context)
>+18
> System.Web.CallHandlerExecutionStep.Execute() +179
> System.Web.HttpApplication.ExecuteStep(IExecutionS tep
>step, Boolean& completedSynchronously) +87
>Here is the code I am using:
>Dim objMail As New Mail.MailMessage()
> Dim objSmtp As Mail.SmtpMail
> Dim ErrorMessage As String = "The following
errors
>occurred: " & ControlChars.CrLf & ex.ToString
> objMail.To = "you@.home.com"
> objMail.From = "me@.work.com"
> objMail.Priority = MailPriority.High
> objMail.BodyFormat = MailFormat.Text
> objMail.Subject = "Error On AddStore.aspx Page"
> objMail.Body = ErrorMessage
> objSmtp.SmtpServer = "localhost"
> objSmtp.Send(objMail)
> objMail = Nothing
> objSmtp = Nothing
>The only thing I changed in this posting was the email
>addresses.
>I have also tried not setting the SmtpServer property to
>let it use the default.
>Not sure what is wrong since I had it working before.
>Thanks
>.
I don't know what I did but it is working again.
Wierd.
>--Original Message--
>I am getting the following error when trying to send the
>mail object:
>COMException (0x80040213): The transport failed to
connect
>to the server.
>]
>[TargetInvocationException: Exception has been thrown by
>the target of an invocation.]
> System.RuntimeType.InvokeDispMethod(String name,
>BindingFlags invokeAttr, Object target, Object[] args,
>Boolean[] byrefModifiers, Int32 culture, String[]
>namedParameters) +0
> System.RuntimeType.InvokeMember(String name,
>BindingFlags invokeAttr, Binder binder, Object target,
>Object[] args, ParameterModifier[] modifiers, CultureInfo
>culture, String[] namedParameters) +473
> System.Web.Mail.LateBoundAccessHelper.CallMethod
(Object
>obj, String methodName, Object[] args) +58
>[HttpException (0x80004005): Could not
>access 'CDO.Message' object.]
> System.Web.Mail.LateBoundAccessHelper.CallMethod
(Object
>obj, String methodName, Object[] args) +113
> System.Web.Mail.CdoSysHelper.Send(MailMessage message)
>+1512
> System.Web.Mail.SmtpMail.Send(MailMessage message) +49
> Forms.AddStore.Page_Error(Object sender, EventArgs e)
>in C:\Inetpub\wwwroot\Forms\AddStore.aspx.vb:137
> System.Web.UI.TemplateControl.OnError(EventArgs e) +109
> System.Web.UI.Page.HandleError(Exception e) +68
> System.Web.UI.Page.ProcessRequestMain() +2065
> System.Web.UI.Page.ProcessRequest() +118
> System.Web.UI.Page.ProcessRequest(HttpContext context)
>+18
> System.Web.CallHandlerExecutionStep.Execute() +179
> System.Web.HttpApplication.ExecuteStep(IExecutionS tep
>step, Boolean& completedSynchronously) +87
>Here is the code I am using:
>Dim objMail As New Mail.MailMessage()
> Dim objSmtp As Mail.SmtpMail
> Dim ErrorMessage As String = "The following
errors
>occurred: " & ControlChars.CrLf & ex.ToString
> objMail.To = "you@.home.com"
> objMail.From = "me@.work.com"
> objMail.Priority = MailPriority.High
> objMail.BodyFormat = MailFormat.Text
> objMail.Subject = "Error On AddStore.aspx Page"
> objMail.Body = ErrorMessage
> objSmtp.SmtpServer = "localhost"
> objSmtp.Send(objMail)
> objMail = Nothing
> objSmtp = Nothing
>The only thing I changed in this posting was the email
>addresses.
>I have also tried not setting the SmtpServer property to
>let it use the default.
>Not sure what is wrong since I had it working before.
>Thanks
>.

0 comments:

Post a Comment