Re: Checking success/failure of sending CDO.Message

Tech-Archive recommends: Fix windows errors by optimizing your registry



then maybe just check for > 0


<melissa.lombard@xxxxxxxxx> wrote in message
news:1117553787.599975.105770@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi, I have been searching all over the internet and MSDN for a simple
> answer and have found none...
> I have some ASP/VbScript code (that I didn't write) to send an email
> from a Win2k server:
> --------------------------------------------------
> set iMsg = CreateObject("CDO.Message")
> iMsg.To = toEmail
> iMsg.From = fromEmail
> iMsg.Subject = subject
> iMsg.TextBody = message
>
> on error resume next
> Dim iCong, Flds, serverError
> serverError = -2147220973
>
> set iConf = CreateObject("CDO.Configuration")
> set iFlds = iConf.Fields
>
> 'Set the CDO configuration fields to send mail on specified external
> smtp server
> iFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing";)
> = 2
> iFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver";)
> = anSMTPaddress
> iFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout";)
> = 5
> iFlds.Update
>
> Set aMessage.Configuration = iConf
> aMessage.send
>
> if err.number = serverError then
> 'redirect to message-failure-page
> else
> 'redirect to message-success-page
> end if
> --------------------------------------------------
> Simple enough. I have found the the serverError variable corresponds to
> a value on this page:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_imessage_send.asp
> In hex, this value corresponds to the CDO_E_FAILED_TO_CONNECT error.
> Now the problem is that, as you can see, there are many other possible
> reasons for Send() to fail. Obviously, I don't want to check for all of
> those error codes.
>
> This page:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_imessage_send.asp
> Isn't much help. Does send() return any value???
>
> This page:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/e2k3/e2k3/_cdo_imessage_send.asp
> Says that it returns S_OK if successful, but I don't know how to import
> this value, and besides that, I'm not sure if this page applies.
>
> I don't care if I know the specific reason, I just want to know if
> there *was* some kind of failure, and do this check in a reasonable
> fashion, preferably by not hard-coding a bunch of numbers...This all
> seems ridiculous to me. Why is something so simple so difficult?
>
> Help! :(
> -Melissa
>


.