Cdosys Error Handling
Contents |
(עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語) HomeLibraryLearnDownloadsRepositoryCommunityForumsBlog Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums server createobject cdo message error handling Answered by: How to obtain text error information from CDO.Message
Capture Cdo Message Error
call Scripting > The Official Scripting Guys Forum! Question 0 Sign in to vote
Cdo Message Get Error
I want tocapture the text description of a message that is triggered by an error trying to send an email message using CDO.Message in
Cdo Message Error Codes
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") cdonts error handling '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:\Attachment2.txt" 'Send mail on error resume next myMail.Send If err.Number <> 0 Then MsgBox err.Number & " - " & err.Description fnSendEmail = err.Number else msgbox "Mail sent OK" fnSendEmail = 0 end if Set myMail = Nothing End Function I run the vbs script from a perl script: use strict; use warnings; print STDERR "Execute vbscript
is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you cdo.message vbscript can post: click the register link above to proceed. To start viewing cdo error messages, select the forum that you want to visit from the selection below. Results 1 to 3 the sendusing configuration value is invalid of 3 Thread: Exception handling with CDO.message Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to 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 Threaded Mode 11-17-2005,03:38 AM #1 4dam View Profile View Forum Posts Registered User Join Date Oct 2005 Posts 32 Exception handling with CDO.message Hi, I am using code based on the following to send an email from a form on my site. One to me, and a confrmation email to the customer. <% theSchema="http://schemas.microsoft.com/cdo/configuration" set cdoConfig=server.CreateObject("CDO.configuration") cdoConfig.fields.item(theSchema http://www.webdeveloper.com/forum/showthread.php?85664-Exception-handling-with-CDO-message & "sendusing")=2 cdoConfig.fields.item(theSchema & "smtpserver")="my.smtp.server" cdoConfig.fields.update set cdoMessage=server.createObject("cdo.message") cdoMessage.configuration=cdoConfig cdoMessage.from=request.form("email") cdoMessage.to=request.form("to") cdoMessage.subject=request.form("subject") cdoMessage.textbody=request.form("message") cdoMessage.send set cdoConfig=nothing set cdoMessage=nothing %> The problem is, that if the customer enters an incorrect email address, the site displays an error message. I have an error page set up, informing the customer that their message couldn't be sent, and directing them back to check their email address, but how do I get it to divert to this page, rather than throwing an unhelpful error message? Any help would be gratefully appreciated. Thanks, Adam Reply With Quote 11-17-2005,11:46 AM #2 Giskard View Profile View Forum Posts Registered User Join Date Nov 2005 Posts 47 Before the cdoMessage.send line add the following: Code: On Error Resume Next then after the cdoMessage.send line add the following: Code: If Err.Number <> 0 Then Response.Redirect("ErrorPage.asp") end if You may want to check the error number to be sure that the e-mail address was the problem. sedlar.net Reply With Quote 11-19-2005,06:26 AM #3 4dam View Profile View Forum Posts Registered User
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site http://stackoverflow.com/questions/24317238/unknown-email-code-from-cdo-message-send-method About Us Learn more about Stack Overflow the company Business Learn more about http://stackoverflow.com/questions/7705005/how-to-check-is-mymail-send-is-true-false hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Unknown email code from CDO.Message cdo message send method up vote 0 down vote favorite 1 I'm trying to send an email via vbscript. Here's my email code: I've hidden the email address of course. In my actual code I'm using a valid email address. Dim objCDO Set objCDO = Server.CreateObject("CDO.Message") objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.oa.caiso.com" objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objCDO.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objCDO.Configuration.Fields.Update objCDO.To = "abcemail@devnull.com" objCDO.From = Sender objCDO.cc = cdo message error "" objCDO.bcc = "" objCDO.Subject = txtSubject objCDO.HTMLBody = Replace(sBody, Chr(10),"
") On Error GoTo 0 On Error Resume Next objCDO.Send If Err.Number <> 0 Then Response.Write "Just after the send command " Response.Write "Err.Number is " & Err.Number & "
" On Error GoTo 0 End If set objCDO = nothing When this code runs I see the following error: Just after the send command Err.Number is -2147220978 Now, when I research this error number there is no reference anywhere for error code -2147220978 In fact, a Google search for the number -2147220978 returns no results at all. Would you have any idea what that odd error code means? email vbscript asp-classic cdo.message share|improve this question edited Jun 19 '14 at 22:53 John Saunders 138k20175319 asked Jun 19 '14 at 22:26 user3669653 6418 Please confirm that you are using ASP Classic, not ASP.NET. –John Saunders Jun 19 '14 at 22:54 add a comment| 3 Answers 3 active oldest votes up vote 3 down vote -2147220978 = 8004020E From CDOSYSERR.h // // MessageId: CDO_E_SENDER_REJECTED // // MessageText: // // The server rejected the sender address. The server response was: %1 // #define CDO_E_SENDER_REJECTED 0x8004020EL D
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to check is myMail.Send is true/false up vote 3 down vote favorite 3 <% 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