3

The CDONTS.NewMail class let's me send email like this:

Set MailObj = Server.CreateObject("CDONTS.NewMail")
MailObj.To = someone@example.com
' set other properties of MailObj
MailObj.Send

I can create my own class in ASP, but it won't let me define a property named "To".

Is there some way I can create a class with a property named "To" in a class that I define?

class MyMail
  Public To          ' this doesn't work!
  Public From        ' this works great!
end class
Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208

1 Answers1

6

It should be possible to mark the identifier with []. As in:

Option Explicit

Class cC
  Public [To]
End Class

Dim oC : Set oC = New cC
oC.To = 4711
Dim i
For i = 0 To 1
    WScript.Echo oC.To
Next

output:

cscript 36585334.vbs
4711
4711

(See here and here for 'escaped names'/[] in another Basic dialect.)

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96