CDO - 即使电子邮件已发送,发送电子邮件也会返回 false
我从 w3school 获取了这个示例,但是当我添加 if 语句来检查电子邮件是否已发送时,即使我收到了电子邮件,它也会显示错误代码。
我不确定 asp 是如何工作的,但我假设 myMail 返回一个布尔值?或者不是吗?如何检查电子邮件是否已发送。
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="[email protected]"
myMail.To="[email protected]"
myMail.HTMLBody = "<h1>This is a message.</h1>"
If myMail.Send Then
Response.AddHeader "Content-type", "application/json"
Response.Write "{ request: 'success'}"
Else
Response.AddHeader "Content-type", "application/json"
Response.Write "{ request: 'failed'}"
End If
set myMail=nothing
%>
I grabbed this example from w3school, however when I add an if statement to check if the email has been sent, it displays the false code even though I receive the email.
Im not sure how asp works, but I'm assuming myMail returns a boolean? Or does it not? How do I check if the email has been sent.
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="[email protected]"
myMail.To="[email protected]"
myMail.HTMLBody = "<h1>This is a message.</h1>"
If myMail.Send Then
Response.AddHeader "Content-type", "application/json"
Response.Write "{ request: 'success'}"
Else
Response.AddHeader "Content-type", "application/json"
Response.Write "{ request: 'failed'}"
End If
set myMail=nothing
%>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.Send方法只是简单地发送消息而不返回响应。
您可以处理因发送消息失败而引发的错误,如下代码所示:
The .Send method just simply sends the message without returning a response.
You can handle an error raised by a failure to send the message something like the code below: