今天终于鼓起勇气用JMAIL了。。。。

以前仿照书本写了几次代码都只能在自己的电脑发送,传到服务器后会出现 未能访问“CDO.Message”对象。后来知道99%的服务器是不支持mailmessage而支持JMAIL。今天终于鼓起勇气用JMAIL了。

以前用到比较好的支持SMTP验证发件程序:shades_smile.gif

ExpandedBlockStart.gif ContractedBlock.gif Public   Class WebForm2 Class WebForm2
InBlock.gif    
Inherits System.Web.UI.Page
InBlock.gif
InBlock.gif#Region 
" Web 窗体设计器生成的代码 "
InBlock.gif

InBlock.gif
    '该调用是 Web 窗体设计器所必需的。
ExpandedSubBlockStart.gifContractedSubBlock.gif
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()Sub InitializeComponent()
InBlock.gif
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif
InBlock.gif    
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
InBlock.gif
    '不要删除或移动它。
InBlock.gif
    Private designerPlaceholderDeclaration As System.Object
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Private Sub Page_Init()Sub Page_Init(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Init
InBlock.gif        
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
InBlock.gif
        '不要使用代码编辑器修改它。
InBlock.gif
        InitializeComponent()
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif
InBlock.gif#
End Region
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Private Sub Page_Load()Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
InBlock.gif        
'在此处放置初始化页的用户代码
InBlock.gif
        Dim email As New System.Web.Mail.MailMessage
InBlock.gif        email.
To = "xxb@263.net"
InBlock.gif
        email.From = "xx@xx.xx"
InBlock.gif
        email.Body = "BODY"
InBlock.gif
        email.Subject = "SUBJECT"
InBlock.gif
        email.BodyFormat = Web.Mail.MailFormat.Text
InBlock.gif
InBlock.gif        email.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate""1")
InBlock.gif        
'将以下三行中中的,第2个参数,设为你的smtp相应值,即可
InBlock.gif
        email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver""210.51.180.238")
InBlock.gif        email.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendusername""XXXX")
InBlock.gif        email.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendpassword""XXXX")
InBlock.gif
InBlock.gif        System.Web.Mail.SmtpMail.Send(email)
InBlock.gif
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif  
ExpandedBlockEnd.gif
End Class

现在用的JMAIL感觉比较好 14.gif。。
None.gif Imports  jmail
None.gif
ExpandedBlockStart.gifContractedBlock.gif
Public   Class WebForm1 Class WebForm1
InBlock.gif    
Inherits System.Web.UI.Page
InBlock.gif
InBlock.gif#Region 
" Web 窗体设计器生成的代码 "
InBlock.gif

InBlock.gif
    '该调用是 Web 窗体设计器所必需的。
ExpandedSubBlockStart.gifContractedSubBlock.gif
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()Sub InitializeComponent()
InBlock.gif
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif
InBlock.gif    
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
InBlock.gif
    '不要删除或移动它。
InBlock.gif
    Private designerPlaceholderDeclaration As System.Object
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Private Sub Page_Init()Sub Page_Init(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Init
InBlock.gif        
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
InBlock.gif
        '不要使用代码编辑器修改它。
InBlock.gif
        InitializeComponent()
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif
InBlock.gif#
End Region
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Private Sub Page_Load()Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load
InBlock.gif        
'在此处放置初始化页的用户代码
InBlock.gif

InBlock.gif        Jmail_Send(
"admin@vb.net.cn""fgvub@163.com""FASDFASDFASD""通知""域名受理""主题测试""210.51.180.238")
InBlock.gif
InBlock.gif
ExpandedSubBlockEnd.gif    
End Sub

InBlock.gif
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
Public Function Jmail_Send()Function Jmail_Send(ByVal fromEmailAddress As StringByVal toEmailAddress As String,
 
ByVal ccEmailAddress As String
ByVal bccEmailAddress As String
ByVal subject As StringByVal body As StringByVal MailServer 
As String) As Boolean
InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif        
Dim email As New jmail.Message
InBlock.gif
InBlock.gif        email.Logging 
= True
InBlock.gif
InBlock.gif        email.Silent 
= True
InBlock.gif
InBlock.gif        email.MailServerUserName 
= "admin@vb.net.cn"  'smtp服务器用户名
InBlock.gif

InBlock.gif        email.MailServerPassWord 
= "xxxxx"  'smtp服务器密码
InBlock.gif

InBlock.gif        email.From 
= fromEmailAddress
InBlock.gif
InBlock.gif        email.Subject 
= subject
InBlock.gif
InBlock.gif        email.Body 
= body
InBlock.gif
InBlock.gif        email.AddRecipient(toEmailAddress)
InBlock.gif
InBlock.gif        
If email.Send(MailServer) Then
InBlock.gif
InBlock.gif            
Return True
InBlock.gif
InBlock.gif        
Else
InBlock.gif
InBlock.gif            
Return False
InBlock.gif
InBlock.gif        
End If
InBlock.gif
ExpandedSubBlockEnd.gif    
End Function

InBlock.gif
InBlock.gif
InBlock.gif
InBlock.gif
ExpandedBlockEnd.gif
End Class

None.gif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值