以下是完整代码,不须控件,本人测试过,正常发送。
'在form上放Command1,Text1.Text,Text2.Tex
Private Sub Command1_Click()
'By Jerry Ye 'http://hi.baidu.com/leaffar/blog/item/86c48e45116daf3a869473d6.html
On Error Resume Next
f = ("123456@)'发送邮箱
smtp = ("smtp.)'发送邮箱服务器
u = ("123456")'发送邮箱用户名
p = ("789")'发送邮箱密码
t = ("22333@)'接收邮箱
m = Text1.Text'邮件标题
msg = Text2.Tex't邮件内容
'将上面的输入框变量全部直接换成默认值就可以实现后台发送邮件,无提示!
NameSpace = "http://schemas.
Set Email = CreateObject("CDO.Message")
Email.From = f
Email.To = t
Email.Subject = m
Email.Textbody = msg
Email.AddAttachment j
With Email.Configuration.Fields
.Item(NameSpace & "sendusing") = 2
.Item(NameSpace & "smtpserver") = smtp
.Item(NameSpace & "smtpserverport") = 25
.Item(NameSpace & "smtpauthenticate") = 1
.Item(NameSpace & "sendusername") = u
.Item(NameSpace & "sendpassword") = p
.Update
End With
Email.Send
End Sub
[[it] 本帖最后由 klj123 于 2008-9-5 15:43 编辑 [/it]]