我这里有一个.Net2002 的例程(5年前写的) 现在还是可以运行的(客户还在使用中-_-) 当然服务器上只装了framework1.0
Private Function SendMail(ByVal subject As String, ByVal bodyHtml As String, ByVal arrAttachfiles As ArrayList, _
ByVal emailTo As String, ByVal emailFrom As String, ByVal bcc As String) As String
Try
Dim mySmtpMail As Object
mySmtpMail = Server.CreateObject("CDONTS.NewMail")
mySmtpMail.MailFormat = 0
mySmtpMail.BodyFormat = 0 'HTML style
mySmtpMail.from = emailFrom
mySmtpMail.to = emailTo
If bcc <> "" Then mySmtpMail.bcc = bcc
mySmtpMail.Subject = subject
mySmtpMail.body = bodyHtml
Dim attachFile As String
For Each attachFile In arrAttachfiles
mySmtpMail.AttachFile(attachFile)
Next
mySmtpMail.send()
mySmtpMail = Nothing
Return "success"
Catch myException As Exception
Return myException.Message
End Try
End Function
End Class
不知道在2005上能不能跑。 没有设置SMTPServer 也许是缺省设定为Localhost?
我现在用的是2005 上个月正好也用到了邮件发送功能 使用的是EnterpriseLibrary的日志功能写入邮件的
在自定义Config文件中声明邮件类型的SINK
<sinks>
<sink xsi:type="EmailSinkData" name="Email Sink" toAddress=xx@xxx.xx fromAddress=xx@xxx.xx subjectLineStarter="------------------------------------------" subjectLineEnder="------------------------------------------" smtpServer="localhost" /></sink>
<category name="Feedback">
<destinations>
<destination name="Email" sink="Email Sink" format="FeedbackFormatter" />
</destinations>
</category>
imports Microsoft.Practices.EnterpriseLibrary.Logging
Dim Log As New LogEntry
Log.Category = "Feedback"
Log.Message = strMailMsg l
Log.Title = strTitle
Log.ExtendedProperties.Add("Recipients", "xxxx@xx.xx,xxx@xx.xx")
Log.ExtendedProperties.Add("Attachment", strFullFilePath)
Logger.Write(Log)
用2005感觉EnterpriseLibrary2.0还是很好用的。。。3.0似乎已经推出了 不过米碰过
不知道对你有没有帮助
我是刚注册来准备提问题的 :)
[此贴子已经被作者于2007-1-4 11:15:31编辑过]