邮件代码不断抛出错误 [英] Mail code keeps throwing error

查看:62
本文介绍了邮件代码不断抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问d的d问题是代码,它没有发送我的邮件,任何线索


pls what is d problem with d is code,its not sending my mail,any lead


<%@ Import Namespace="System.Net.Mail" %>

<SCRIPT Runat="Server">

Sub Send_Email (Src As Object, Args As EventArgs)

   If MailFrom.Text <> "" _
      AND MailTo.Text <> "" _
      AND Subject.Text <> "" _
      AND Body.Text <> "" Then
         Try
            Dim MailClient = New SmtpClient("mail.eaglejobsng.com")
            MailClient.Send(MailFrom.Text,MailTo.Text,Subject.Text,Body.Text)
            MailMsg.Text = "Email sent"
         Catch
            MailMsg.Text = "Error in sending email!"
         End Try
   End If

End Sub

</SCRIPT>

<form Runat="Server">

<h3>Send Email</h3>

<table border="1" style="border-collapse:collapse">
<tr>
   <td style="font-weight:bold; background-color:#E0E0E0">To:</td>
   <td><asp:TextBox id="MailTo" Width="200" Runat="Server"/></td>
</tr>
<tr>
   <td style="font-weight:bold; background-color:#E0E0E0">From:</td>
   <td><asp:TextBox id="MailFrom" Width="200" Runat="Server"/></td>
</tr>
<tr>
   <td style="font-weight:bold; background-color:#E0E0E0">Subject:</td>
   <td><asp:TextBox id="Subject" Width="300" Runat="Server"/></td>
</tr>
<tr>
   <td style="font-weight:bold; background-color:#E0E0E0">Message:</td>
   <td><asp:TextBox id="Body" Runat="Server"

            TextMode="MultiLine" Rows="5" Width="300"

            Font-Name="Arial"/></td>
</tr>
</table>
<br/>
<asp:Button Text="Send Email" OnClick="Send_Email" Runat="Server"/>
<asp:Label id="MailMsg" ForeColor="#FF0000" Runat="Server"/>

</form>



作者更新:

错误消息始终为发送电子邮件时出错"



Author''s update:

the error message is always "Error in sending email"

推荐答案

您的问题很多.

1-您使用txt说话,就像白痴一样
2-您不告诉我们错误消息

我会说这不是公共服务器的可能性很大,因此您提供的代码无法正常工作,因为它无法连接到服务器,但是基于它是不可能知道的缺乏信息.
Your problems are many.

1 - you use txt speak, like a moron
2 - you don''t tell us the error message

I''d say the odds are good that this is not a public server, and so the code you''ve given does not work because it can''t connect to the server, but it''s impossible to know ,based on this lack of information.


我和克里斯蒂安在一起.

但是以下帖子将为您提供帮助,

使用SmtpClient类发送电子邮件的简单有效的方法 [
I am with Christian.

But the below post will help you,

A Simple But Effective Way to Send an Email using SmtpClient Class[^]


可能是由于各种原因.您需要一一看待它们.
港口开放吗?防火墙权限到位了吗?
进一步确保已在Web.Config中配置SMTP配置:
It can be because of various reasons. You need to look at them one by one.
Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration in Web.Config:
<system.net>
   <mailSettings>
     <smtp from="abc@somedomain.com">
       <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
     </smtp>
   </mailSettings>
</system.net>


如果需要,请查看此Microsoft Video教程:
使用ASP.NET发送来自网站的电子邮件 [


If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]


这篇关于邮件代码不断抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆