gpt4 book ai didi

email - 如何检查 myMail.Send 是 true/false

转载 作者:行者123 更新时间:2023-12-02 12:49:44 25 4
gpt4 key购买 nike

    <%
Dim sent
Dim YourName
Dim YourEmail
Dim YourMessage
Set myMail2=CreateObject("CDO.Message")
YourName = Trim(Request.Form("Name"))
YourEmail = Trim(Request.Form("Email"))
YourMessage = Trim(Request.Form("Message"))

Dim Body
Dim body2
Body = Body & "Their Name: " & VbCrLf & YourName & VbCrLf & VbCrLf
Body = Body & "Their Email: " & VbCrLf & YourEmail & VbCrLf & VbCrLf
Body = Body & "Their Message: " & VbCrLf & YourMessage & VbCrLf & VbCrLf

Set myMail=CreateObject("CDO.Message")
myMail.Subject="A New Enquiry!"
myMail.From="admin@musicalmatters.co.uk"
myMail.To="james@devine.eu"
myMail.TextBody=Body
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.1and1.com"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing



body2="Thank you for contacting us!" & VbCrLf & "This is just a brief message to let you know your form was submitted successfully!"& VbCrLf & VbCrLf & "You may reply to this address, but you may not necessarily receive a reply, "& "you should receive a reply in 1-2 business day(s)!"& VbCrLf & "Thank you very much,"& VbCrLf & VbCrLf & "Musical Matters."& VbCrLf & "admin@musicalmatters.co.uk"

Set myMail2=CreateObject("CDO.Message")
myMail2.Subject="Thanks for Contacting Us!"
myMail2.From="admin@musicalmatters.co.uk"
myMail2.To=YourEmail
myMail2.TextBody=body2

myMail2.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail2.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.1and1.com"
'Server port
myMail2.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail2.Configuration.Fields.Update
myMail2.Send

If myMail2.Send="" Then
Response.Redirect("http://www.musicalmatters.co.uk/success.htm")
set myMail2=nothing

Else
Response.Redirect("http://www.musicalmatters.co.uk/error.htm")
set myMail2=nothing
End If

我的 asp 脚本的问题是我需要检查电子邮件是否已发送,并根据结果将它们重定向到错误或成功页面。

    If myMail2.Send="" Then 
Response.Redirect("http://www.musicalmatters.co.uk/success.htm")
set myMail2=nothing

Else
Response.Redirect("http://www.musicalmatters.co.uk/error.htm")
set myMail2=nothing
End If

在上面的代码中 mymail2.Send=""因为我正在测试一些东西,我知道我必须将值更改为 true 或 false,请尽快回答!

提前致谢!

最佳答案

如果电子邮件地址具有有效的语法并且 SMTP 服务器已启动并正在运行,则 Send 方法永远不会抛出错误,即使电子邮件地址不存在也是如此。

没有办法 100% 知道电子邮件是否到达目的地 - 我能想到的一件事是检查(使用 FSO)中的 BadMailQueue 文件夹发送后几秒钟后,SMTP 根目录就会出现,如果它们包含新条目,则意味着出现了问题。

但是,当您使用外部邮件服务时,您必须联系他们并寻求一种在投递失败时以某种方式收到通知的方法。

关于email - 如何检查 myMail.Send 是 true/false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7705005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com