Send email error : could not access 'cdo.message' object.

G

Guest

Hello.
I have a strange question about send email in .net.
I use the following code to send email.

Sub SendMail(ByVal mailFrom As String, _
ByVal mailTo As String, _
ByVal mailSubject As String, _
ByVal mailServer As String, _
ByVal mailBody As String)
Dim mm As New System.Web.Mail.MailMessage
Dim Mail As System.Web.Mail.SmtpMail
mm.From = mailFrom
mm.To = mailTo
mm.Subject = mailSubject
mm.Body = mailBody
mm.BodyFormat = System.Web.Mail.MailFormat.Html
Mail.SmtpServer = mailServer
Mail.Send(mm)
End Sub

I get this error:

System.Web.HttpException: could not access 'cdo.message' object.

but if I instead

"Mail.SmtpServer = mailServer"

to

"Mail.SmtpServer.Insert(0, mailServer)"

the program can run correctly.

Do you know why? Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top