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.
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.