我试过这个:
Dim mail
mail = Server.CreateObject("CDO.Message")
mail.To = consul.Email
mail.From = "ADM@CFChamplain.ca"
mail.Subject = subj
mail.HTMLBody = Bdy
mail.Send()
mail = Nothing
它给了我以下错误: “SendUsing”配置值无效。
答案 0 :(得分:0)
这是我用于我的应用程序的代码,它适用于ASP.NET。您需要在班级顶部为.net.mail执行导入。 - >进口System.Net.Mail
Public Sub SendEmail(ByVal Sentfrom As String, ByVal Recipient As String, _ ByVal SubjectLine As String, ByVal Messagebody As String)Dim SmtpEngine As New SmtpClient SmtpEngine.Host = "yourhost.com" Try SmtpEngine.Send(Sentfrom & "@taco.com", Recipient & "@taco.com", SubjectLine, Messagebody) Catch ex As Exception My.Application.Log.WriteException(ex) End Try End Sub
答案 1 :(得分:0)
尝试此功能:
Public Sub SendMsg(from, dest, subj, body)
Dim msg, flds, conf
Set msg = CreateObject("CDO.Message")
Set conf = CreateObject("CDO.Configuration")
Set flds = conf.Fields
flds(cdoSendUsingMethod) = cdoSendUsingPort
flds(cdoSMTPServer) = "smtp.xyz.org"
flds(cdoSMTPServerPort) = 25
'if use SMTP authentication...
flds(cdoSMTPAuthenticate) = cdoBasic
flds("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxxx"
flds("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "zzzzzz"
'... or, without SMTP authentication
flds(cdoSMTPAuthenticate) = cdoAnonymous
flds.Update
On Error Resume Next
With msg
Set .Configuration = conf
.BodyPart.CharSet = "utf-8"
.TextBodyPart.CharSet = "utf-8"
.To = dest
.From = from
.Subject = subj
.TextBody = body
.Send
End With
On Error Goto 0
set msg = nothing
set conf = nothing
set flds = nothing
End Sub