在研究了下cdo.message组件和jmail组件之后,尝试了下,发现jmail容易乱码,而cdo.message却不大会发生乱码现象。
为了让msn spaces能够通过邮件发送生成日志,
首先,进入msn spaces下,“选项”-“邮件发布”,下开启邮件发布功能,并且选择“立即发布”。这样你将得到一个有密文的邮件地址,这个就是将来的日志收件人,假设为rain518.xxx@spaces.live.com
其次,新建一个空白asp文件,其内容为
[code]
<% public Function Send(strTitle,strBriefBody) On Error Resume Next SendMail="#err" err.Clear Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing" Const cdoSendUsingPort=2 Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver" Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport" Const cdoSMTPConnectionTimeout="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" Const cdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" Const cdoSMTPEncoding="http://schemas.microsoft.com/cdo/configuration/languagecode" Const cdoBasic=1 Const cdoSendUserName="http://schemas.microsoft.com/cdo/configuration/sendusername" Const cdoSendPassword="http://schemas.microsoft.com/cdo/configuration/sendpassword" Dim objConfig ' As CDO.Configuration Dim objMessage ' As CDO.Message Dim Fields ' As ADODB.Fields strBriefBody1=strBriefBody strTitle1=strTitle1 Set objConfig = Server.CreateObject("CDO.Configuration") Set Fields = objConfig.Fields With Fields .Item(cdoSendUsingMethod) = cdoSendUsingPort .Item(cdoSMTPServer) = "mail.xxx.com" '你的发送邮件所在的邮件smtp地址 .Item(cdoSMTPServerPort) = 25 .Item(cdoSMTPConnectionTimeout) = 10 .Item(cdoSMTPAuthenticate) = cdoBasic .Item(cdoSendUserName) = "xxx" '你的发送邮件的登录名 .Item(cdoSendPassword) = "***" '你的发送邮件的密码 .Update End With Set objMessage = Server.CreateObject("CDO.Message") Set objMessage.Configuration = objConfig With objMessage .To = "rain518.xxx@spaces.live.com" '第一步设置中得到的日志收件地址 .From = "webmaster@baifaqimei.com" '这里显示发件人是谁 .Subject = strTitle .HTMLBody = strBriefBody .Send End With Set Fields = Nothing Set objMessage = Nothing Set objConfig = Nothing if err.number=0 then SendMail="#ok" End If end function %>
[/code]
命名为sendmail.asp文件
第三步,打开blogpost.asp文件,在第一行加入
[code]
[/code]
然后再57行左后,在
[code]
postLog = lArticle.postLog
[/code]
之后加入如下代码
[code]
dim strTitle,strBriefBody,strPre,strid
strBriefBody=lArticle.logMessage
strTitle=lArticle.logTitle
strPre= "
==========
白发齐眉网自动发送
==========
"
if len(strBriefBody)>300 then
strBriefBody =left(strBriefBody,300) & "…"
Else
strBriefBody = strBriefBody
end if
strid=Clng(lArticle.getid())
strBriefBody = Replace(strBriefBody,chr(13)&chr(10),"
")
strBriefBody= strBriefBody & "
点这里浏览完整的文章"
strBriefBody=strPre & strBriefBody
if Request.Form("checkbox")= "checkbox" then
Call Send(strTitle,strBriefBody)
end if
[/code]
第四步,修改
class\cls_logAction.asp文件
在50行左后,新加一个函数
[code]
public function getid()
sqlString="Select top 1 * FROM blog_Content orDER BY log_ID DESC "
weblog.Open sqlString,Conn,1,3
getid=weblog("log_ID")
weblog.close
end function
[/code]
本代码在pjblog v2.7 build05下通过没问题,应该在2.6上也是没问题的,只是可能blogpost文件的行数有点不一样,另,因本人时间匆忙,没来得及优化,参数传递以及变量的设置可能有多余,请看官自行修改。
附上修改好的文件,如pjblog没有修改过,可以直接覆盖更新。
不能保证一定正确,请修改前务必备份!
近期评论