|
查看: 1450|回复: 9
|
VB.Net 2005 send email
[复制链接]
|
|
|
有一些问题想请教各位前辈,我用web service 弄了一个send mail 的function...在自己公司的local network 里test 没有问题,可以send 去给每一架pc的ms outlook mail box。可是当我把它移去live server 时,就不可以了。。
- Try
- Dim insMail As New Net.Mail.MailMessage(New Net.Mail.MailAddress(strFrom), New Net.Mail.MailAddress(strTo))
- With insMail
- .Subject = strSubject
- .Body = strBody
- If Not strAttachments.Equals(String.Empty) Then
- Dim strFile As String
- Dim strAttach() As String = strAttachments.Split(";")
- For Each strFile In strAttach
- .Attachments.Add(New System.Net.Mail.Attachment(strFile.Trim()))
- Next
- End If
- End With
- Dim smtpServer As New Net.Mail.SmtpClient
- smtpServer.Host = "smtp.8zr.com"
- smtpServer.Credentials = New Net.NetworkCredential("tech@8zr.com", "12345678", "www.8zr.com")
- smtpServer.Send(insMail)
- Catch e As Net.Mail.SmtpException
- Return e.ToString
- End Try
复制代码
(红色的部分是我pass进来的value)我有将smtpClient 的 smtp host 改成live server的, 也有设定 username 和pwd..可是就是发送不到
以下是Error code
System.Net.Mail.SmtpException: Failure sending mail. ---> System.ComponentModel.Win32Exception: The token supplied to the function is invalid at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, SecurityStatus& statusCode) at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob) at System.Net.Mail.SmtpNtlmAuthenticationModule.Authenticate(String challenge, NetworkCredential credential, Object sessionCookie) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at Service.SendMail(String strFrom, String strTo, String strCC, String strSubject, String strBody, String strAttachments, String strSMTPServer) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\SendEmail\App_Code\Service.vb:line 69
请问各位前辈是什么问题呢...?谢谢 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 6-5-2008 12:31 AM
|
显示全部楼层
没人回复吗?
我试了很多次依然是不可以 |
|
|
|
|
|
|
|
|
|
|
发表于 7-7-2008 02:43 PM
|
显示全部楼层
|
你有SET PORT NUMBER吗?PORT25 BLOCKeD了 |
|
|
|
|
|
|
|
|
|
|
发表于 14-7-2008 07:58 PM
|
显示全部楼层
问题出在这里吗?
smtpServer.Send(insMail) |
|
|
|
|
|
|
|
|
|
|
发表于 26-7-2008 08:31 PM
|
显示全部楼层
楼主
这是本人自己用vb.net做的一个简单小东西
用来send email的
http://rapidshare.com/files/132582066/SendMail.zip.html
你下载了用visual studio开
然后到web.config改一改

我当时是用本身的streamyx account来当email的host的
你的情况应该改为
<smtp from="tech@8zr.com">
<network host="smtp.8zr.com" password="123456" userName="tech@8zr.com"/>
</smtp>
看看是否帮到你
再不然这里还有一些我用过的code
希望可以帮到你
Dim myEmail As New SmtpClient("smtp.8zr.com")
Dim SmtpUser As New System.Net.NetworkCredential("tech@8zr.com", "123456")
Dim from As New MailAddress("tech@8zr.com") //这个其实只是会出现在sender那边的email address罢了
Dim recipients As New MailAddress(txtEmail.Text)
Dim message As New MailMessage(from, recipients)
message.Subject = "Email Testing"
message.Body = "Email content" //这里写你要的Email内容
myEmail.DeliveryMethod = SmtpDeliveryMethod.Network
myEmail.UseDefaultCredentials = False
myEmail.Credentials = SmtpUser
myEmail.Send(message)
还有就是想问一下
那个“12345678“是你的password吧
为什么要pass进来呢
那个应该是放你的Hosting的Email host password
只需set在那边就可以了阿 |
|
|
|
|
|
|
|
|
|
|
发表于 3-9-2008 09:52 AM
|
显示全部楼层
asp.net c# send email
各位大大,
小弟急需关于如何在asp.net c# send email 的code!
当我按“submit”,那个表格就会 mail 到相关人的邮箱,
相关人的邮此是在database take out.
help me pls!
urgent |
|
|
|
|
|
|
|
|
|
|
发表于 10-9-2008 10:05 PM
|
显示全部楼层
原帖由 seekeong 于 3-9-2008 09:52 AM 发表 
各位大大,
小弟急需关于如何在asp.net c# send email 的code!
当我按“submit”,那个表格就会 mail 到相关人的邮箱,
相关人的邮此是在database take out.
help me pls!
urgent
可以参考VB.net 的写法 |
|
|
|
|
|
|
|
|
|
|
发表于 30-9-2008 10:26 PM
|
显示全部楼层
|
查一查你的port number 和 server address |
|
|
|
|
|
|
|
|
|
|
发表于 1-10-2008 01:28 AM
|
显示全部楼层
|
免费 的 live mail support pop3 吗?我是用 gmail 的。 |
|
|
|
|
|
|
|
|
|
|
发表于 28-10-2008 12:06 AM
|
显示全部楼层
我的Final Year Project 也是用gmail 的SMTP。
可行的。 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|