Jump to content

No error popup on error?


Recommended Posts

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

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

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 fails

Did 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...