Alwin
asked on
How check for a successful SEND using CDO?
Hi Experts,
A Form has to be submitted.
When using aspmail, something like this can be done:
if Mailer.SendMail then
response.write ("Your message was sent")
else
response.write ("Your message was not sent. ")
response.write ("The error was: " & Mailer.Response)
end if
But how do I check if the message was sent successfully using CDO?
Set objMessage = Server.CreateObject("CDO.M essage")
With objMessage
.To = ...
.From = ...
.Subject = ...
.TextBody = ...
.Send
End With
Set objMessage = Nothing
What to do after objMessage.Send ?
Thanks a lot!
A Form has to be submitted.
When using aspmail, something like this can be done:
if Mailer.SendMail then
response.write ("Your message was sent")
else
response.write ("Your message was not sent. ")
response.write ("The error was: " & Mailer.Response)
end if
But how do I check if the message was sent successfully using CDO?
Set objMessage = Server.CreateObject("CDO.M
With objMessage
.To = ...
.From = ...
.Subject = ...
.TextBody = ...
.Send
End With
Set objMessage = Nothing
What to do after objMessage.Send ?
Thanks a lot!
You can either check for err.number, or check the SMTP logs for successful mail. I don't think CDO provide such functionality internally.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is the code which reads through the badmailfolder and retrieves the recipients list....
<%
Dim objFSO,objFold,objfile
CONST FolderPath="F:\Inetpub\Mai lroot\Drop "
'** CREATE THE FSO **
Set objFSO=Server.CreateObject ("Scriptin g.FileSyst emObject")
'** CREATE FOLDER
Set objFold=objFSO.GetFolder(F olderPath)
' ** OPEN EACH MAIL **
For each objMail in objFold.Files
Set objfile=objFSO.OpenTextFil e(FolderPa th&"\"&obj Mail.Name, 1,false)
do while objfile.AtEndOfStream = false
lnNo=objfile.Line
' ** LINE 2 DISPLAYS THE RECIPIENT **
If lnNo=2 Then
Response.Write objfile.ReadLine
' ** LINE 4 DISPLAYS THE TIME **
elseif lnNo=4 Then
Response.Write objfile.ReadLine
Response.Write("<br>")
else
objfile.skipLine
End If
Loop
objfile.Close
Set objfile=Nothing
Next
Set objFold=nothing
Set objFSO=nothing
%>
You'll have to modify the folder path to your Badmail directory.
The output is returned to the browser... However, with slight modification, you can make the script to write to a text file and forward the text file to your business users.
Cheers!!
<%
Dim objFSO,objFold,objfile
CONST FolderPath="F:\Inetpub\Mai
'** CREATE THE FSO **
Set objFSO=Server.CreateObject
'** CREATE FOLDER
Set objFold=objFSO.GetFolder(F
' ** OPEN EACH MAIL **
For each objMail in objFold.Files
Set objfile=objFSO.OpenTextFil
do while objfile.AtEndOfStream = false
lnNo=objfile.Line
' ** LINE 2 DISPLAYS THE RECIPIENT **
If lnNo=2 Then
Response.Write objfile.ReadLine
' ** LINE 4 DISPLAYS THE TIME **
elseif lnNo=4 Then
Response.Write objfile.ReadLine
Response.Write("<br>")
else
objfile.skipLine
End If
Loop
objfile.Close
Set objfile=Nothing
Next
Set objFold=nothing
Set objFSO=nothing
%>
You'll have to modify the folder path to your Badmail directory.
The output is returned to the browser... However, with slight modification, you can make the script to write to a text file and forward the text file to your business users.
Cheers!!
ASKER
Hi,
I cannot access any badmail folder, this form (website) is not hosted on my own server, but somewhere else.
So far the err.number seems to offer the best solution.
By the way, how to know what the CDO errorcode is?
The errorcodes description can be found here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_error_codes.asp
Or is this only for win2000 and not for winNT?
Thanks
I cannot access any badmail folder, this form (website) is not hosted on my own server, but somewhere else.
So far the err.number seems to offer the best solution.
By the way, how to know what the CDO errorcode is?
The errorcodes description can be found here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_error_codes.asp
Or is this only for win2000 and not for winNT?
Thanks
You don't need to know the error codes in ASP, just that it's not zero:
if err.number <> 0 then
'there was an error in the page
response.write err.number & ": " & err.description
end if
if err.number <> 0 then
'there was an error in the page
response.write err.number & ": " & err.description
end if
Why 'B' ?
@Alwin - Note that I said check err.number in the first post. And, B grades are never good when someone gives you the right answer. Learn to use the board properly or Experts will not help you!
ASKER
Hi alorentz,
I know that you were the first to mention err.number.
But when I asked about CDO error codes you said that I don't need to know about CDO error codes.
I said CDO error codes and not err.number
I wondered of I could use CDO errorcode to be able to give the right feedback in case of error.
If I ask about something then I don't expect to get "you don't need to know" as an answer.
Thats's why
Regards,
Alwin
I know that you were the first to mention err.number.
But when I asked about CDO error codes you said that I don't need to know about CDO error codes.
I said CDO error codes and not err.number
I wondered of I could use CDO errorcode to be able to give the right feedback in case of error.
If I ask about something then I don't expect to get "you don't need to know" as an answer.
Thats's why
Regards,
Alwin
That's because there's no such thing as CDO error codes!
ASKER
Hi jitganguly
Never knew that A or B was so important.
Sorry about that.
Using the err.number is a good solution, but I was not convinced that there are no better solutions.
That's why I gave you "good"
Sorry again.
I 'll remeber it for the next time.
Regards,
Alwin
Never knew that A or B was so important.
Sorry about that.
Using the err.number is a good solution, but I was not convinced that there are no better solutions.
That's why I gave you "good"
Sorry again.
I 'll remeber it for the next time.
Regards,
Alwin
ASKER
Hi alorentz
What about the link in my posting:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_error_codes.asp
Bye
Alwin
What about the link in my posting:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_error_codes.asp
Bye
Alwin
Never used them, don't think they are for ASP....they look more SMTP or MFC based.