i tried this:
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
It gave me the following error: The "SendUsing" configuration va开发者_开发百科lue is invalid.
This is the code I use for my applications, it's for ASP.NET. You'll need to do an import at the top of your class for .net.mail. --> Imports 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
Try this function:
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
精彩评论