错误-至少需要“发件人"或“发件人"字段之一,但均未找到. [英] Error - At least one of the From or Sender fields is required, and neither was found.
本文介绍了错误-至少需要“发件人"或“发件人"字段之一,但均未找到.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么会显示错误,至少需要发件人"或发件人"字段之一,但都没有找到?但是我已经给出了所有领域.
我的代码在下面
<%@ 页面 语言 =" VB" EnableSessionState 错误" EnableViewState =" 跟踪 =" 调试 =" <%@ 导入 命名空间 =" %>
< 脚本 语言 VB" =" 服务器" 子 Page_Load(发件人 as Object ,E as EventArgs)
如果 Page.IsPostBack 然后
lblResponse.Text = "
结束 如果
结束 子
Sub btn_Click(发送方 as Object ,e 作为 System.EventArgs)
如果 Request.Form(" )<> " 然后
Dim objMail As 新建 MailMessage()
objMail.From = "
objMail.收件人 = Request.Form(" )
objMail.Subject = Request.Form(" )
objMail.Body = Request.Form(" )
objMail.BodyFormat = MailFormat.Text
SmtpMail.SmtpServer = "
SmtpMail.Send(objMail)
其他
lblResponse.Text = "
结束 如果
结束 子
</ 脚本 >
< html >
< 头部 >
< 样式 >
.主 {字体家族 : Verdana; 字体大小 : 12px; }
.标题 {字体家族 : Verdana; 字体大小 : 18px; 字体重量 : </ 样式 >
< /head >
< 正文 >
< span =" 标题" align center" > 从发送电子邮件
一个ASP.NET页< /span >
< asp:Label 类 =" id lblResponse " runat 服务器" > < br >
< br >
< 表单 =" POST" 名称 MainForm" runat =" >
< 表 >
< tr >
< td =" main" 对齐 右" > 电子邮件:< /td >
< td =" main" < 类型 =" 类 =" 名称 =" 值 =" >> < /td >
< /tr >
< tr >
< td =" main" 对齐 右" >
主题:< /td >
< td =" main" < 类型 =" 类 =" 名称 =" 值 =" > < /td >
< /tr >
< tr >
< td =" main" 对齐 右" >
valign ="top">消息:< /td >
< td =" main" < 名称 =" cols =" =" > >< /textarea > < /td >
< /tr >
< tr >
< td =" main" < >
< td =" main" < 类型 =" id =" önServerClick =" 值 ="
runat = " / > < /td >
< /tr >
< /table >
< /form >
< /body >
< /html >
< /br > < /br >
解决方案
您的From
字段不包含有效的电子邮件地址,因此服务器将拒绝它. VB中的代码并不能解决问题:您可能确实需要授权,就像Medhi上次问这个问题时所建议的那样.
看一看:它可能会告诉您您需要做什么. 使用C#发送带有或不带有附件的电子邮件:通用例程. [ ^ ]
Why error is showing At least one of the From or Sender fields is required, and neither was found? But i have given all field.
My code is given below
<%@ Page Language="VB" EnableSessionState="False" EnableViewState="False" Trace="False" Debug="True"%>
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
Sub Page_Load(Sender as Object, E as EventArgs)
If Page.IsPostBack Then
lblResponse.Text = "Your email has been sent."
End If
End Sub
Sub btn_Click(sender as Object, e as System.EventArgs)
If Request.Form("Email") <> "" Then
Dim objMail As New MailMessage()
objMail.From = "Email"
objMail.To = Request.Form("contact@kamnatrust.com")
objMail.Subject = Request.Form("Subject")
objMail.Body = Request.Form("Message")
objMail.BodyFormat = MailFormat.Text
SmtpMail.SmtpServer = "webmail.kamnatrust.com"
SmtpMail.Send(objMail)
Else
lblResponse.Text = "Please enter an email address."
End If
End Sub
</script>
<html>
<head>
<style>
.main {font-family:Verdana; font-size:12px;}
.title {font-family:Verdana; font-size:18px; font-weight:bold;}
</style>
</head>
<body>
<span class="title" align="center">Send email from
an ASP.NET page</span>
<asp:Label class="main" id="lblResponse" runat="server"/> <br>
<br>
<form method="POST" name="MainForm" runat="server">
<table>
<tr>
<td class="main" align="right">Email:</td>
<td class="main"><input type="text" class="main" name="Email" value=""></td>
</tr>
<tr>
<td class="main" align="right">
Subject:</td>
<td class="main"><input type="text" class="main" name="Subject" value=""></td>
</tr>
<tr>
<td class="main" align="right">
valign="top">Message:</td>
<td class="main"><textarea name="Message" cols="50" rows="8"></textarea></td>
</tr>
<tr>
<td class="main"> </td>
<td class="main"><input type="Submit" id="btnSubmit" önServerClick="btn_Click" value="Send"
runat="server" /></td>
</tr>
</table>
</form>
</body>
</html>
</br></br>
解决方案
Your From
field does not contain a valid email address so the server will reject it.
Rewriting the same code into VB isn''t going to fix the problem: You probably do need authorisation, as Medhi suggested the last time you asked this question.
Have a look at this: it may show you what you need to do. Sending an Email in C# with or without attachments: generic routine.[^]
这篇关于错误-至少需要“发件人"或“发件人"字段之一,但均未找到.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文