佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1452|回复: 9

VB.Net 2005 send email

[复制链接]
发表于 2-5-2008 03:57 PM | 显示全部楼层 |阅读模式
有一些问题想请教各位前辈,我用web service 弄了一个send mail 的function...在自己公司的local network 里test 没有问题,可以send 去给每一架pc的ms outlook mail box。可是当我把它移去live server 时,就不可以了。。

  1.     Try
  2.         Dim insMail As New Net.Mail.MailMessage(New Net.Mail.MailAddress(strFrom), New Net.Mail.MailAddress(strTo))
  3.             With insMail

  4.                 .Subject = strSubject
  5.                 .Body = strBody
  6.                 If Not strAttachments.Equals(String.Empty) Then
  7.                     Dim strFile As String
  8.                     Dim strAttach() As String = strAttachments.Split(";")
  9.                     For Each strFile In strAttach
  10.                         .Attachments.Add(New System.Net.Mail.Attachment(strFile.Trim()))
  11.                     Next
  12.                 End If
  13.             End With

  14.             Dim smtpServer As New Net.Mail.SmtpClient
  15.             smtpServer.Host = "smtp.8zr.com"
  16.             smtpServer.Credentials = New Net.NetworkCredential("tech@8zr.com", "12345678", "www.8zr.com")
  17.             smtpServer.Send(insMail)

  18.         Catch e As Net.Mail.SmtpException
  19.             Return e.ToString
  20.         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


请问各位前辈是什么问题呢...?谢谢
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 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
回复

使用道具 举报

Follow Us
发表于 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
回复

使用道具 举报


ADVERTISEMENT

发表于 1-10-2008 01:28 AM | 显示全部楼层
免费 的 live mail support pop3 吗?我是用 gmail 的。
回复

使用道具 举报

发表于 28-10-2008 12:06 AM | 显示全部楼层
我的Final Year Project 也是用gmail 的SMTP。
可行的。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-12-2025 02:59 PM , Processed in 0.106746 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表