简体   繁体   English

如何创建具有“To”属性的ASP类(如CDONTS.NewMail)?

[英]How can I create ASP class with “To” property (like CDONTS.NewMail)?

The CDONTS.NewMail class let's me send email like this: CDONTS.NewMail类让我发送这样的电子邮件:

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". 我可以在ASP中创建自己的类,但它不会让我定义名为“To”的属性。

Is there some way I can create a class with a property named "To" in a class that I define? 有没有办法在我定义的类中创建一个名为“To”的属性的类?

class MyMail
  Public To          ' this doesn't work!
  Public From        ' this works great!
end class

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.) 在此处此处查看另一种基本方言中的'转义名称'/ []。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM