我现在用上面我说的发邮件我现在遇到几个问题
Option Explicit
Dim objMail As ObjectPrivate Sub Command1_Click()
Set objMail = CreateObject("CDONTS.newmail")
objMail.Send " dd", "[email protected]", "Title", "测试"
Set objMail = Nothing
End Sub
Private Sub Command2_Click()
Set objMail = CreateObject("CDONTS.newmail")
With objMail
.From = "[email protected] "
.To = "[email protected]"
.Subject = "附件"
.Body = "成功否"
.AttachFile "c:\1.txt", "1.txt"
.Send
End With
Set objMail = Nothing
End Sub
1。这个程序在有点机器上不能用提示说active不能创建对象!我注册CDONTS和应用了!还是不行!
2.我就是没有提示问题,但是我没有收到我发的信不知道为什么!我曾经就这个程序试成功过!
3.我看网上本来是这么写的Dim objMail as Object 
Set objMail=CreateObject("CDFONTS.DLL") 这样写有问题吗?

解决方案 »

  1.   

    CDONTS需要一个有效的MailAddress作为发信地址Set objMail=CreateObject("CDFONTS.DLL") 肯定是不对的
    CDONTS.NewMail是一个组件的类,创建对象必须按照规范来写
      

  2.   

    It's for you...private function sendmail()Dim ObjMail As New CDONTS.NewMail
    Dim mail_body As String
    mail_body = "<html><head>"
    mail_body = mail_body + "<title>Order</title></head><body>"
    mail_body = mail_body + "<table>"
    ...
    mail_body = mail_body + "</table>"
    mail_body = mail_body + "</body></html>"
       With ObjMail
      .From = "Administrator"
      .To = "[email protected]"
      
       .Cc = "[email protected]"
      '.Bcc = "[email protected]"
      .Subject = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      .Body = mail_body
      .BodyFormat = 0
      .MailFormat = 0
      '.AttachFile (FileName)
      .Send
      
    End WithSet ObjMail = NothingEnd Function