Cdo Message Error Handling Vbscript
Contents |
(עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語) HomeLibraryLearnDownloadsRepositoryCommunityForumsBlog Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From vbscript cdo send mail multiple recipients My Forums Answered by: How to obtain text error vbscript cdo email information from CDO.Message call Scripting > The Official Scripting Guys Forum! Question 0 Sign error handling in vbscript examples in to vote I want tocapture the text description of a message that is triggered by an error trying to send an error handling in vbscript tutorial 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
Vbscript Error Handling Best Practices
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:\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
Challenges C# Getting Started Examples Development Software Books KiXtart Getting Started Examples Links Tools Books Perl
Vbscript Error Handling Line Number
Getting Started Examples Links Tools Books PowerShell Getting Started vbscript on error continue Examples Links Tools Books Regular Expressions Getting Started Expressions Examples Links Tools Books Rexx Getting vbscript resume on error Started Examples OS/2 LAN Server Links Tools Books VBScript & WSH Getting Started VBScript Techniques Examples HTA & WSC Examples Links Tools Books 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 Challenges Technologies WMI Getting Started Examples Links Tools Books ADSI Getting Started Examples Links Tools Books Silent Installs General Windows Installer Specific Software Software Requirements Hardware Requirements Books Batch Files Windows Resource Kits KiXtart Perl PowerShell Regular Expressions Rexx VBScript & WSH C# WMI ADSI HTML, JavaScript & http://www.robvanderwoude.com/vbstech_internet_email.php CSS Off-Topic Scripting Tools Batch Utilities Resource Kits Compilers Editors Code Generators Regular Expressions Automation Tools VBScript Add-Ons Visual Studio Printing Tools Inventory Tools Shell Extensions File Viewers Backup Security The making Of... Miscellaneous Tweaks Web Stuff Conversions My Photo Galleries About This Site Disclaimer News FAQ Search What's New Objective Site Policy Your Preferences Credits The Making Of... Contact Failed Mail Donate VBScript Scripting Techniques > Network > Send e-Mail Send e-Mail CDOSYS VBScript Code: WScript.Echo EMail( "John Doe
is your first visit, be sure to check out the FAQ by clicking the link above. You http://www.webdeveloper.com/forum/showthread.php?85664-Exception-handling-with-CDO-message may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 3 of 3 Thread: Exception handling with CDO.message Tweet Thread Tools Show Printable Version Email this Page… Subscribe error handling to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to 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 error handling in 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 & "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.Redir