asp.net中用mailmessage发email时,出现的错误

cyberguy 2002-12-23 10:30:45
在用System.Web.Mail下的mailmessage发email时,出现以下错误:
Can not access "CDO.Message" Object,这是什么原因???如何解决???
...全文
69 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
csdn_bob 2002-12-24
  • 打赏
  • 举报
回复
你是用这种方式我就无能为力了!(不懂):)
cyberguy 2002-12-24
  • 打赏
  • 举报
回复
搞定了,只要将SmtpMail.SmtpServer = ""就可以了,它可以调用本地的smtp报务
cyberguy 2002-12-23
  • 打赏
  • 举报
回复
请大家看看(特别是afengsunwin(afeng) )谢谢

Public Function SendEmail(ByVal sMailARL As ArrayList) As Boolean

Dim mailMsg As New MailMessage()
Dim arlAttached As ArrayList
Dim bReturn As Boolean



'************************************************
Dim services() As ServiceController = ServiceController.GetServices
Dim service As ServiceController
Dim blnHasSmtpService As Boolean = False

' Loop through all the services on the machine and find the SMTP Service.
For Each service In services
If service.ServiceName.ToLower = "smtpsvc" Then
blnHasSmtpService = True
Exit For
End If
Next

If Not blnHasSmtpService Then
Throw New Exception("You do not have SMTP Service installed on this " & _
"machine. Please check the Readme file for information on how " & _
"to install SMTP Service.")
End If

' Ensure the SMTP Service is running. If not, start it.
If Not service.Status = ServiceControllerStatus.Running Then
'Dim frmStatusMessage As New frmStatus()
'frmStatusMessage.Show("SMTP Service not currently running. " & _
' "Starting service...")
Try
service.Start()
'frmStatusMessage.Close()
Catch

throw new Exception("There was an error when attempting " & _
"to start SMTP Service. Please consult the Readme " & _
"file for more information.")
End Try
End If

'*************************************************
With mailMsg
.From = CStr(sMailARL(0))
.To = CStr(sMailARL(1))
.Cc = CStr(sMailARL(2))
.Bcc = CStr(sMailARL(3))
.Subject = CStr(sMailARL(4))
.Body = CStr(sMailARL(5))
.Priority = CType(sMailARL(6), MailPriority)

'arlAttached = CType(sMailARL(7), ArrayList)
'If Not IsNothing(arlAttached) Then
' Dim mailAttachment As Object
' For Each mailAttachment In arlAttached
' .Attachments.Add(mailAttachment)
' Next
'End If
End With


' See the Readme file for more information.
SmtpMail.SmtpServer = "dev-server"

' Use structured error handling to attempt to send the email message and
' provide feedback to the user about the success or failure of their
' attempt.
Try
SmtpMail.Send(mailMsg)

bReturn = True
Catch exp As Exception
Throw New Exception("The following problem occurred when attempting to " & _
"send your email: " & exp.Message)
Return False
End Try
Return bReturn
End Function
afengsunwin 2002-12-23
  • 打赏
  • 举报
回复
这个web service是自己写的(用来练习)还是调用别人的,
web service写的肯定对吗?
cyberguy 2002-12-23
  • 打赏
  • 举报
回复
我是通过web service 在服务器调用一个function,而服务器上是有smtp服务的(服务器是E文win2k server)
afengsunwin 2002-12-23
  • 打赏
  • 举报
回复
对,先按楼上兄弟的试试。
如果不是这个问题,把代码贴出来,
保证帮你搞定
csdn_bob 2002-12-23
  • 打赏
  • 举报
回复
你是在自己的机器上吧!
可能是你的机器没有配制smtp等服务!
你到一个支持mail的服务器上再试试吧!

62,249

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧