Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How check for a successful SEND using CDO?

Posted on 2004-03-29
12
Medium Priority
?
367 Views
Last Modified: 2008-03-06
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.Message")
With objMessage

      .To       = ...
      .From     = ...
      .Subject  = ...
      .TextBody = ...
      .Send
End With

Set objMessage = Nothing

What to do after objMessage.Send ?

Thanks a lot!
0
Comment
Question by:Alwin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 10708535
You can either check for err.number, or check the SMTP logs for successful mail.  I don't think CDO provide such functionality internally.
0
 
LVL 20

Accepted Solution

by:
jitganguly earned 750 total points
ID: 10708659
Do this

Set objMessage = Server.CreateObject("CDO.Message")
With objMessage

     .To       = ...
     .From     = ...
     .Subject  = ...
     .TextBody = ...
     .Send
End With

If err.number <> 0 Then
   Response.Write "Error in Sending "
   response.end
End if

generally when it fails, it goes to badmail folder. You may want to manipulate that
0
 
LVL 21

Expert Comment

by:ap_sajith
ID: 10710526
Here is the code which reads through the badmailfolder and retrieves the recipients list....

<%
Dim objFSO,objFold,objfile
CONST FolderPath="F:\Inetpub\Mailroot\Drop"
'** CREATE THE FSO **
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
'** CREATE FOLDER
Set objFold=objFSO.GetFolder(FolderPath)
' ** OPEN EACH MAIL **
For each objMail in objFold.Files
     Set objfile=objFSO.OpenTextFile(FolderPath&"\"&objMail.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!!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Alwin
ID: 10710923
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
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10713260
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
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 10714198
Why 'B' ?
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10714245
@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!
0
 

Author Comment

by:Alwin
ID: 10715031
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

0
 
LVL 31

Expert Comment

by:alorentz
ID: 10715099
That's because there's no such thing as CDO error codes!
0
 

Author Comment

by:Alwin
ID: 10715142
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


0
 

Author Comment

by:Alwin
ID: 10715168
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10715253
Never used them, don't think they are for ASP....they look more SMTP or MFC based.  
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question