惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
L
LangChain Blog
T
The Blog of Author Tim Ferriss
J
Java Code Geeks
Y
Y Combinator Blog
月光博客
月光博客
雷峰网
雷峰网
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
A
About on SuperTechFans
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
小众软件
小众软件
H
Help Net Security
Last Week in AI
Last Week in AI
B
Blog RSS Feed
宝玉的分享
宝玉的分享
N
Netflix TechBlog - Medium
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog

博客园 - 北极熊,我来了!

C#获取类以及类下的方法(用于Asp.Net MVC) 使用JavaScript判断用户是否为手机设备 手机端页面自适应解决方案 Asp 邮件发送代码 js 日期字符串转换成日期类型,判断星期几 浅析a标签的4个伪类 C#读取Rss功能函数 《中文防止乱码的万能解决方案》 《小偷程序:自动获取百度天气预报》 Asp.NET使用HTML控件上传文件 《JS两级联动菜单学习全接触》 活动目录ADSI实现添加系统帐号问题!!! ADSI管理Windows2003系统帐号 《IP地址和数字之间转化的算法》 《单域名下整合动网、动易、OBlog程序》 JS读取XML数据 Asp.NET读取Excel数据 [XML系列]Flash读取XML数据 《省市联动功能菜单的实现》
中国频道空间使用Jmail发送邮件
北极熊,我来了! · 2007-05-14 · via 博客园 - 北极熊,我来了!

     最近在弄一个客户的网站,需要使用Asp+JMail发送邮件,在确定空间是支持Jmail组件之后,终于决定要把两年前的老伙计搬出来了,下面是全部的函数代码:

'判断服务器是否支持Jmail发信组建
Function IsObjInstalled(strClassString)
    On Error Resume Next
    IsObjInstalled 
= False
    Err 
= 0
    Dim xTestObj
    Set xTestObj 
= Server.CreateObject(strClassString)
    If 
0 = Err Then IsObjInstalled = True
    Set xTestObj 
= Nothing
    Err 
= 0
End Function

'创建Jmail发信函数
function SendMail(EMail,Subject,MailBody,Priority)
On error resume next
Set JMail
=Server.CreateObject("JMail.Message"'建立发送邮件的对象
if err then
SendMail
= "<br><li>没有安装JMail组件</li>"
err.clear
exit function
end 
if
JMail.silent
=true '屏蔽例外错误,返回FALSE跟TRUE两值
JMail.logging = true '启用邮件日志
jmail.Charset = "GB2312" '邮件的文字编码为国标   
JMail.ContentType = "text/html" '邮件的格式为HTML格式
JMail.AddRecipient Email '邮件收件人的地址  
JMail.From = "china@feisky.com" '发件人的E-MAIL地址 
JMail.MailServerUserName = "china@feisky.com"'登录邮件服务器所需的用户名
JMail.MailServerPassWord = "456123"'登录邮件服务器所需的密码
JMail.Subject=Subject'邮件的标题
JMail.Body=MailBody'邮件的内容
JMail.Priority=Priority  '邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值    
JMail.Send("smtp.feisky.com")'执行邮件发送(通过邮件服务器地址)
JMail.Close
Set JMail
=nothing
end function

Function IsValidEmail(email)
    dim names, name, i, c
    IsValidEmail 
= true
    names 
= Split(email, "@")
    
if UBound(names) <> 1 then
       IsValidEmail 
= false
       exit function
    end 
if
    
for each name in names
        
if Len(name) <= 0 then
            IsValidEmail 
= false
            exit function
        end 
if
        
for i = 1 to Len(name)
            c 
= Lcase(Mid(name, i, 1))
            
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
               IsValidEmail 
= false
               exit function
             end 
if
       next
       
if Left(name, 1= "." or Right(name, 1= "." then
          IsValidEmail 
= false
          exit function
       end 
if
    next
    
if InStr(names(1), "."<= 0 then
        IsValidEmail 
= false
       exit function
    end 
if
    i 
= Len(names(1)) - InStrRev(names(1), ".")
    
if i <> 2 and i <> 3 then
       IsValidEmail 
= false
       exit function
    end 
if
    
if InStr(email, ".."> 0 then
       IsValidEmail 
= false
    end 
if
End function

       代码其实很简单,以前也是网络上收藏的,只是比较经典吧而且是有效可以使用的,现在Baidu方便是方便,就是急用的时候经常会搜索不出你真正想要的东西,诶,网络垃圾泛滥了。有一点需要注意的是,中国频道的空间,那些都是一样的,就是发送帐号需要写全,不然不能正确发送的。