Reputation: 9049
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
%>
Upvotes: 0
Views: 2062
Reputation: 13533
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:
On Error Resume Next
myMail.Send
If Err.Number = 0 then
Response.ContentType="application/json"
Response.Write "{ request: 'success'}"
Else
Response.ContentType="application/json"
Response.Write "{ request: 'failed'}"
End If
Upvotes: 2