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

问题描述

请问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"

推荐答案



<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[^]


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

08-20 10:37
查看更多