Re: HELP: changing code from CDONTS to CDO by Jim
Jim
Sat Dec 11 18:26:58 CST 2004
Oh yeah,
I forgot to tell you how to declare the typelib for CDO. Add the following
to the top of your ASP file.
<!--
metadata type="typelib"
uuid="CD000000-8B95-11D1-82DB-00C04FB1625D"
name="CDO for Windows 2000 Library"
-->
- Jim Rodgers
"Jim" <Jim@discussions.microsoft.com> wrote in message
news:A5866C9D-F2A1-44AB-A1BC-5EB5B84F4D93@microsoft.com...
> Jim,
>
> Thanks for that!
>
> Regards,
> Jim
>
> "Jim Rodgers" wrote:
>
> > Here's my minimalistic solution...
> >
> > '------------------------------------------------
> > Dim cdoMessage, strBodyHTML, strBodyText, strAttFileName
> > '------------------------------------------------
> > Set cdoMessage = CreateObject("CDO.Message")
> > cdoMessage.From = "SenderPerson@Somewhere.Com"
> > cdoMessage.To = "RecipientPerson@SomewhereElse.Com"
> > cdoMessage.Subject = "Confirmation eMail"
> > '------------------------------------------------
> > cdoMessage.TextBody = strBodyText
> > cdoMessage.HTMLBody = strBodyHTML
> > cdoMessage.AddAttachment strAttFileName
> > '------------------------------------------------
> > cdoMessage.Send
> > '------------------------------------------------
> > Set cdoMessage = Nothing
> > '------------------------------------------------
> >
> > - Jim Rodgers
> >
> >
> > "Jim" <Jim@discussions.microsoft.com> wrote in message
> > news:EB975182-33C0-4CDD-B3B6-04FA2F5134BD@microsoft.com...
> > > THink I got it..
> > >
> > > Here's the new code that worked for me:
> > >
> > > Function SendEMail(FromAddress, ToAddress, BodyText, SubjectText)
> > > Dim objMailCDO
> > > Dim bSendMail
> > >
> > > bSendMail = True
> > >
> > > Set objMailCDO = Server.CreateObject("CDO.Message")
> > > objMailCDO.From = FromAddress
> > > objMailCDO.To = ToAddress
> > > objMailCDO.Subject = SubjectText
> > > objMailCDO.TextBody = BodyText
> > > On Error Resume Next
> > > objMailCDO.Send
> > > If Err.number > 0 Then bSendMail = False
> > > On Error Goto 0
> > > Set objMailCDO = Nothing
> > > SendEMail = bSendMail
> > > End Function
> > >
> > > "Jim" wrote:
> > >
> > > > L.S.,
> > > >
> > > > In order to make sending mail work on my W2K3 hosting account I
figured
> > out
> > > > that CDONTS is not supported anymore... :(
> > > >
> > > > So.. I am now changing to CDO and have to change the following code.
As
> > I've
> > > > recently started programming I don;t exactly know how to change the
> > code.. I
> > > > hope that somebody can help. Here's the code that I used and that
worked
> > fine
> > > > on my WinXP machine (with CDONTS). What do I have to do to get it to
> > work on
> > > > the WIN2K3 (without CDONTS):
> > > >
> > > > Function SendEMail(FromAddress, ToAddress, BodyText, SubjectText)
> > > > Dim objMailCDO
> > > > Dim bSendMail
> > > >
> > > > bSendMail = True
> > > >
> > > > Set objMailCDO = Server.CreateObject("CDO.NewMail")
> > > > objMailCDO.From = FromAddress
> > > > objMailCDO.To = ToAddress
> > > > objMailCDO.Subject = SubjectText
> > > > objMailCDO.Body = BodyText
> > > > On Error Resume Next
> > > > objMailCDO.Send
> > > > If Err.number > 0 Then bSendMail = False
> > > > On Error Goto 0
> > > > Set objMailCDO = Nothing
> > > > SendEMail = bSendMail
> > > > End Function
> > > >
> > > > Thanks so much for your help!
> > > >
> > > > Kind regards,
> > > > Jimt
> >
> >
> >