版主,请问,我的代码里,有什么缺少的地方吗?
还有,一定要使用那段引用吗?
我这里有一个.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编辑过]
感谢楼上的~~~
我先用你的方法试一下。
不知道你有没有用system.net.mail里的类编写呢?
可以的话,能不能试试看。这样也好交流一下。不然就算用你的方法解决了,我心里还是不舒服。呵呵。
不把这个搞明白。。心里闷~~
强烈建议楼主更换SMTP Server做个测试,比如把SMTP server改成163,加上用户和口令后 如果发送邮件能成功 那么就是本机SMTP服务设置有问题
另外 如果你做测试的邮箱是新申请的 也有可能会收不到邮件
我上个月,不,是去年(其实也就是上周),测试Email发送的时候 新申请了一个163账号,结果无论如何都收不到;而使用原来的163邮箱就能收到。至于为什么就是天知道了。
版主,请问,我的代码里,有什么缺少的地方吗?
还有,一定要使用那段引用吗?
你把发送的邮件的主题这些东西都加上试试.