tom13 Posted May 4, 2007 Share Posted May 4, 2007 Hi, I have a function which I use to send e-mails but when it fails it gives me an error, is it possible to execute another piece of script and don't show an error popup instead? So, if @error then ... ? (couldnt get this to work myself) My code: Func SendEmail($e_Sender, $e_Recipient, $e_Subject, $e_Text, $e_File) $objMessage = ObjCreate("CDO.Message") With $objMessage .Subject = $e_Subject .Sender = $e_Sender .From = $e_Sender .To = $e_Recipient .TextBody = $e_Text ;.HtmlBody = $e_Text ; uncomment to send a HTML mail and comment line above ;.AddAttachment = $e_File ; <== I REMOVED THIS as we don't have an attachment EndWith With $objMessage.Configuration.Fields .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $smtpserver .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $smtpuser .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $smtppass .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587 .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 .Update EndWith $objMessage.Send Return EndFunc ;==>SendEmail It is for when $objMessage.Send fails Link to comment Share on other sites More sharing options...
Will66 Posted May 4, 2007 Share Posted May 4, 2007 you may already know it.....here's the asp way cdoMessage.Send if Err.Number <> 0 then SendMail = "Email send failed: " & Err.Description & "." end if set cdoMessage = Nothing set cdoConfig = Nothing exit function Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 4, 2007 Share Posted May 4, 2007 Hi,I have a function which I use to send e-mails but when it fails it gives me an error, is it possible to execute another piece of script and don't show an error popup instead?So, if @error then ... ? (couldnt get this to work myself)...It is for when $objMessage.Send failsDid you define a COM error event handler in your script? Read the help file under Object/COM reference. There is an example of an error handler. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ToKicoBrothers Posted May 4, 2007 Share Posted May 4, 2007 If I understood you well, try: If @error Then MsgBox (0, "Error", "Error") My Scripts: SimplePlayer 1.0 - A very simple music player. PCInfo 1.2 - A script that displays PC information. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now