Cdonts Error Trapping
(עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語) HomeLibraryLearnDownloadsRepositoryCommunityForumsBlog Ask a question Quick access Forums home Browse forums cdo.message error codes users FAQ Search related threads Remove From vbscript cdo message error handling My Forums Answered by: How to obtain text error information from CDO.Message cdo error call Scripting > The Official Scripting Guys Forum! Question 0 Sign in to vote I want tocapture the text cdo.message.1 the transport failed to connect to the server description of a message that is triggered by an error trying to send an email message using CDO.Message in a vbscript. Here is the script: Dim sMessage dim rc sMessage = "press OK to send email" 'Display the text in a messagebox Msgbox sMessage rc=fnSendEmail msgbox "return code from fnsendemail is " & rc wscript.quit rc Function fnSendEmail() 'Create an object of CDO type Set myMail=CreateObject("CDO.Message") 'Enable SSL Authentication myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True 'Enable basic smtp authentication myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'Specify Yahoo SMTP server and Port Number myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.mail.yahoo.com" myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Specify user id and password myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "me@yahoo.com" myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword" 'Update the configuration fields myMail.Configuration.Fields.Update 'Specify email properties myMail.Subject = "Sending Email from QTP" myMail.From = "me@yahoo.com" myMail.To = "metoo@insight.rr.com" myMail.CC = "" myMail.BCC = "" myMail.TextBody = "This is the Text Body" 'Send 2 attachments in the mail 'myMail.AddAttachment "D:\Attachment1.txt" 'myMail.AddAttachment "D:\Attachme
Unanswered Topics Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP Pro Code Clinic CDO Email Errors not trapped by On Error User Name Remember Me? Password Reminder Password Register Register | FAQ | Members List | Calendar | Today's Posts | Search ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here. Search Forums Show Threads Show Posts Advanced Search Find All Thanked Posts Go to Page... Welcome to the p2p.wrox.com Forums. You https://social.technet.microsoft.com/Forums/scriptcenter/en-US/cb4eb074-f00c-4ddc-9047-6d2552271249/how-to-obtain-text-error-information-from-cdomessage-call?forum=ITCG are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free . http://p2p.wrox.com/asp-pro-code-clinic/9830-cdo-email-errors-not-trapped-error.html Thread Tools Display Modes #1 (permalink) February 26th, 2004, 06:04 PM ebycer Registered User Join Date: Feb 2004 Location: , , . Posts: 3 Thanks: 0 Thanked 0 Times in 0 Posts CDO Email Errors not trapped by On Error Hi, I've got a problem where my apps email service is sporadic.Sometimes works like a charm, other times fails miserably. What's supposed to happen is the following: When an e-mail is successfully sent -- exit successfully and do nothing further. When an error occurs on the email Send command 1) Log the error # and description, body, subject, and distribution in a table 2) Generate a message for the user explaining that the e-mail has NOT been sent, but everything else is OK 3) Give them a link to redirect them so they continue as if no error had occurred. Unfortunately, when the e-mail fails, nothing is recorded, nor is the user notified that an error occurred. Any ideas? (Note: Using Access 2000 on Win Server 2003) Here is the code for all three procedures.Sorry if the indentation is messy... Sub Sub_Process_Email_Error(str_Redirect) If str_Redirect <> "myFiles.asp" Then Response.Write "The E-mail was not sent due to an error.The QAS Developer has been notified and will resend the e-mail for you.
" Response.Write "All data was saved, and all other events have occurred.
" Response.Write "Please click
van GoogleInloggenVerborgen veldenZoeken naar groepen of berichten
Tutorials MSDN Communities Hub Official Docs Security Stump the SQL Guru! XML Info Information: Feedback Author an Article Published: Thursday, June 03, 1999 Error Handling in ASP, Part 2 Page 1 -continued- The question now is how to we "trap" errors? Well, after any ADO call that accesses the database, we will want to put the following lines: If Err.number <> 0 then TrapError Err.description End If You will want to put this after all ADO calls that communicate directly with the database. This includes ConnectionObject.Open, ConnectionObject.Execute, and RecordsetObject.Open. Now, you may be wondering where the sub TrapError is defined: we're about to do that. Create a file called ErrorHandler.asp and put it in your /include or /scripts directory. In ErrorHandler.asp, we will have the following subs: TrapError
ProcessErrors Let's look at the code for ErrorHandler.asp: <% Dim strErrorMessage Dim bolErrors 'Initialize variables strErrorMessage = "" 'The error messages for tech. support bolErrors = False 'Have we found any errors yet? 'Now our two subs sub TrapError(strError) bolErrors = True 'Egad, we've found an error! strErrorMessage = strErrorMessage & strError & ", " end sub 'If there are any errors, this function will email tech. support sub ProcessErrors() if bolErrors then 'Send the email Dim objCDO Set objCDO = Server.CreateObject("CDONTS.NewMail") objCDO.To = "techsupport@mysite.com" objCDO.From = "techsupport@mysite.com" objCDO.Subject = "AN ADO ERROR OCCURRED" objCDO.Body = "At " & Now & " the following errors occurred on " & _ "the page " & Request.ServerVariables("SCRIPT_NAME") & _ ": " & _ chr(10) & chr(10) & strErrorMessage objCDO.Send Set objCDO = Nothing 'Now, we've got to print out something for the user Response.Write "There has been a database error. Technical Support " & _ "has already been notified. You will be informed when " & _ "this issue is resolved. Thank you for your patience!" end if end sub That's all there is to it! Of course, you need to have the SMTP piece installed on your webserver. (See this article for more information on sending email using CDO.). Now, at the top of all your pages that you want to use the error handling routines, you'll need to include ErrorHandler.asp like so: (See this article for more information on using includes.) You also need to make a call to the ProcessErrors sub at the end of all your ASP scripts which use this Error Trapping. So, the last line in the ASP file would be <% P