on an article: ASP Development Example of WAP Simple mail system
3) Send mail
Figure Five
The implementation of the function of sending mail mainly uses the Jmail.message object to complete, about the object to use the relevant knowledge has been described in the previous, you can be the above functional introduction and source control to read, so as to help understand the entire mail delivery process, of course, if the WM elements for HTMLF elements, such a simple we b mail to send the function is completed, send.asp for the mail to send the page sendok.asp send processing page for the message
Send.asp
〈% @LANGUAGE = "VBSCRIPT" codepage= "65001"%〉
〈%response.contenttype = "TEXT/VND.WAP.WML; Charset=utf-8 "%〉
〈?xml version= "1.0" encoding= "Utf-8"?
〈! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml"
〈wml〉
〈card id= "main" title= "Outbox"
〈p〉
〈%
User=request ("User")
Pwd=request ("pwd")
%〉
Recipient:
〈input type= "text" title= "Recipient" Name= Tomail "size=" "maxlength=" 50 "/〉〈br/〉
Title:
〈input type= "text" title= "title" Name= "Subject" size= "a" maxlength= "50"/〉
〈br/〉 content:
〈input type= "text" title= "content" name= "body" size= "" maxlength= "250"/〉〈br/〉
〈do type= "Accept" label= "send" optional= "false"
〈go href= "sendok.asp?user=〈%=user%〉&pwd=〈%=pwd%〉" method= "post" accept-charset= "Utf-8"
〈postfield name= "from" value= "$ (from)"/〉
〈postfield name= "Tomail" value= "$ (tomail)"/〉
〈postfield name= "Subject" value= "$ (subject)"/〉
〈postfield name= "Body" value= "$ (body)"/〉〈/go〉
〈/do〉
〈/p〉
〈p〉
〈a href= "main.asp?user=〈%=user%〉&pwd=〈%=pwd%〉" return to the mailbox 〈/a〉〈/p〉
〈/card〉
〈/wml〉
Sendok.asp
〈% @LANGUAGE = "VBSCRIPT" codepage= "65001"%〉
〈%response.contenttype = "TEXT/VND.WAP.WML; Charset=utf-8 "%〉
〈?xml version= "1.0" encoding= "Utf-8"?
〈! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml"
〈wml〉
〈card id= "main" title= "Send Mail"
〈p〉
〈%
User=request ("User")
Pwd=request ("pwd")
Tomail=request ("Tomail")
' From=request.form ("from")
Subject=request.form ("Subject")
Body=request.form ("Body")
servermail=user+ "@sohu. com"
Dim JMail
Set Jmail=server. CreateObject ("Jmail.message")
Jmail.silent=true
Jmail.charset = "gb2312"
Jmail.from = "" &ServerMail& "" is the sender.
Jmail.addrecipient Tomail
Jmail.subject = "" &subject& ""
JMail. Body= "&body&"----------your current users to win the palm of the mail system, please visit: http://www.palmmail.cn Mail through the world! ----------"
Jmail.mailserverusername =user
Jmail.mailserverpassword = pwd
Jmail.maildomain = "Www.sohu.com"
jmail.priority=2
Sendok=jmail.send ("smtp.sohu.com")
Set jmail=nothing
If Sendok Then
Response.Write "Send success!〈a href= ' main.asp?user=" &user& "&pwd=" &pwd& "" "Back to Mailbox 〈/a〉"
Else
Response.Write "Send failed!〈a href= ' send.asp?user=" &user& "&pwd=" &pwd& "" "Back to Mailbox 〈/a〉"
End If
%〉
〈/p〉
〈/card〉
〈/wml〉
4) Receive mail
Figure Six
Receive mail mainly consists of two parts, the first is divided into mailing list, according to the total number of messages (Pop3.count) for paging display. The second part of the specific content of each letter, including the attachment of the detection function, because the mobile phone browsing can not open the attachment, so the system only to detect the attachment and to remind users whether the message contains mail function.
The source code is as follows:
Mailing list: email_list.asp
〈% @LANGUAGE = "VBSCRIPT" codepage= "65001"%〉
〈%response.contenttype = "TEXT/VND.WAP.WML; Charset=utf-8 "%〉
〈?xml version= "1.0" encoding= "Utf-8"?
〈! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml"
〈wml〉
〈card id= "main" title= "Inbox"
〈p〉
〈%
User=request ("User")
Pwd=request ("pwd")
Dim perpage_num,curpage,totalpage
Perpage_num=3 ' Sets the number of display bars per page
If Request ("page") = "" Then
Curpage=1 ' current page
Else
Curpage=int (Request ("page")
End If
Set POP3 = Server.CreateObject ("JMAIL.POP3")
Pop3.connect user,pwd, "http://pop3.sohu.com"
' POP3 connection username, password, POP3 address
If Pop3.count mod perpage_num〈〉0 then
Totalpage=int (Pop3.count/perpage_num) +1
Else
Totalpage=int (Pop3.count/perpage_num)
End If
Response.Write ("You now have the & pop3.count &" email. "&totalpage&" page, current "&curpage&" page 〈br/〉---------------------〈br/〉 ")
If Pop3.count〉0 then ' if no message is displayed without message
If Pop3.count〉=perpage_num*curpage Then
For i= (curpage-1) *perpage_num to curpage*perpage_num-1%〉
〈a href= "email_info.asp?id=〈%=i+1%〉&user=〈%=user%〉&pwd=〈%=pwd%〉&page=〈%=curpage%〉" 〉〈%= Pop3.messages.item (i+1). Subject%〉--〈%=pop3.messages.item (i+1). date%〉〈/a〉〈br/〉
〈%next
%〉
〈%if curpage〉1 then%〉
〈a href= "email_list.asp?page=〈%=curpage-1%〉&user=〈%=user%〉&pwd=〈%=pwd%〉" last page 〈/a〉
〈%end if%〉
〈%if Int (curpage) 〈int (totalpage) then%〉
〈a href= "email_list.asp?page=〈%=curpage+1%〉&user=〈%=user%〉&pwd=〈%=pwd%〉" next page 〈/a〉
〈%end if%〉
〈%
Else
For i= (curpage-1) *perpage_num to pop3.count-1%〉
〈a href= "email_info.asp?id=〈%=i+1%〉&user=〈%=user%〉&pwd=〈%=pwd%〉&page=〈%=curpage%〉" 〉〈%= Pop3.messages.item (i+1). Subject%〉--〈%=pop3.messages.item (i+1). date%〉〈/a〉〈br/〉
〈%next%〉
〈%if curpage〉1 then%〉
〈a href= "email_list.asp?page=〈%=curpage-1%〉&user=〈%=user%〉&pwd=〈%=pwd%〉" last page 〈/a〉
〈%end if%〉
〈%if Int (curpage) 〈int (totalpage) then%〉
〈a href= "email_list.asp?page=〈%=curpage+1%〉&user=〈%=user%〉&pwd=〈%=pwd%〉" next page 〈/a〉
〈%end if%〉
〈%
End If
Else
Response.Write ("No mail!")
End If
POP3. Disconnect
%〉
〈/p〉
〈p〉
〈a href= "main.asp?user=〈%=user%〉&pwd=〈%=pwd%〉" return to the mailbox 〈/a〉
〈/p〉
〈/card〉
〈/wml〉
Message Details: email_info.asp
〈% @LANGUAGE = "VBSCRIPT" codepage= "65001"%〉
〈%response.contenttype = "TEXT/VND.WAP.WML; Charset=utf-8 "%〉
〈?xml version= "1.0" encoding= "Utf-8"?
〈! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml"
〈wml〉
〈card id= "main" title= "View Mail"
〈p〉
〈%
User=request ("User")
Pwd=request ("pwd")
Id=request ("id")
Page=request ("page")
Set POP3 = Server.CreateObject ("JMAIL.POP3")
' POP3 connection username, password, POP3 address
Pop3.connect user,pwd, "http://pop3.sohu.com"
Set msg = POP3. Messages.item (ID)
ReTo = ""
RECC = ""
Set Recipients = Msg. Recipients
Separator = ","
For i = 0 to Recipients.count-1
If i = recipients.count-1 Then
Separator = ""
End If
Set re = Recipients.item (i)
If Re. Retype = 0 Then
ReTo = ReTo & Re. Name & Re. EMail & Separator
Else
RECC = ReTo & Re. Name & Re. EMail & Separator
End If
Next
Body=msg.body
Body=replace (Body, "" "," ")
Body=replace (Body, "", "")
Set Attachments = Msg. Attachments
%〉
〈a href= "email_title.asp?user=〈%=user%〉&pwd=〈%=pwd%〉&page=〈%=page%〉" return to previous page 〈/a〉〈a href= "reply.asp?user=〈% =user%〉&pwd=〈%=pwd%〉&mailto=〈%=msg. from%〉 "Reply 〈/a〉〈a href=" email_del.asp?user=〈%=user%〉&pwd=〈%=pwd%〉&id=〈%=id%〉 "Delete 〈/a〉
〈/p〉
〈p〉
Sender: 〈%= msg. FromName%〉--〈%=msg.date%〉〈br/〉
Title: 〈%= Msg. Subject%〉〈br/〉
Content: 〈%= Body%〉〈br/〉
〈%
If Attachments.count〉0 Then
Response. Write ("The letter contains attachments, please check through the network!") ")
End If
POP3. Disconnect
%〉
〈/p〉
〈p〉
〈a href= "email_list.asp?user=〈%=user%〉&pwd=〈%=pwd%〉&page=〈%=page%〉" return to previous page 〈/a〉〈a href= "reply.asp?user=〈%= User%〉&pwd=〈%=pwd%〉&mailto=〈%=msg. from%〉 "Reply 〈/a〉〈a href=" email_del.asp?user=〈%=user%〉&pwd=〈%=pwd%〉&id=〈%=id%〉 "Delete 〈/a〉
〈/p〉
〈/card〉
〈/wml〉
5) Delete Mail
This function is the same as the mail reply function, for the message to view a child function of the page, through the MessageID delivery implementation to delete the message.
Source: email_del.asp
〈% @LANGUAGE = "VBSCRIPT" codepage= "65001"%〉
〈%response.contenttype = "TEXT/VND.WAP.WML; Charset=utf-8 "%〉
〈?xml version= "1.0" encoding= "Utf-8"?
〈! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml"
〈wml〉
〈card id= "main" title= "delete Success"
〈p〉
〈%
User=request ("User")
Pwd=request ("pwd")
Id=request ("id")
Set POP3 = Server.CreateObject ("JMAIL.POP3")
' POP3 connection username, password, POP3 address
Pop3.connect user,pwd, "http://pop3.sohu.com"
Pop3.deletesinglemessage ID
POP3. Disconnect
Set jmail=nothing
Response.Write delok& "Delete successful!〈a href= ' email_list.asp?user=" &user& "&pwd=" &pwd& "" Return inbox 〈/a〉 "
%〉
〈/p〉
〈/card〉
〈/wml〉
6) Reply mail
Replying to a message is basically the same as sending a message, only the sender from the original manual input to pass through the URL parameters, of course, can also be the main content of the message to the reply to the main body, but because of today's mobile phone access to the basic use of traffic charges, in order to reduce traffic on the omitted these functions, the specific code is as follows:
Reply.asp
〈% @LANGUAGE = "VBSCRIPT" codepage= "65001"%〉
〈%response.contenttype = "TEXT/VND.WAP.WML; Charset=utf-8 "%〉
〈?xml version= "1.0" encoding= "Utf-8"?
〈! DOCTYPE WML public "-//wapforum//dtd WML 1.1//en" "Http://www.wapforum.org/DTD/wml_1.1.xml"
〈wml〉
〈card id= "main" title= "Outbox"
〈p〉
〈%
User=request ("User")
Pwd=request ("pwd")
Tomail=request ("mailto")
%〉
Recipient:
〈%=tomail%〉〈br/〉
Title:
〈input type= "text" title= "title" Name= "Subject" size= "8" maxlength= "50"/〉
〈br/〉 content:
〈input type= "text" title= "content" name= "Body" size= "8" maxlength= "250"/〉〈br/〉
〈do type= "Accept" label= "send" optional= "false"
〈go href= "sendok.asp?user=〈%=user%〉&pwd=〈%=pwd%〉&tomail=〈%=tomail%〉" method= "post" accept-charset= "Utf-8" 〉
〈postfield name= "Subject" value= "$ (subject)"/〉
〈postfield name= "Body" value= "$ (body)"/〉〈/go〉
〈/do〉
〈/p〉
〈p〉
〈a href= "email_list.asp?user=〈%=user%〉&pwd=〈%=pwd%〉" Back to Inbox 〈/a〉〈br/〉
〈a href= "main.asp?user=〈%=user%〉&pwd=〈%=pwd%〉" return to the mailbox 〈/a〉〈/p〉
〈/card〉
〈/wml〉
Although this system can achieve the mail send, receive, reply, delete and other functions, but many aspects are very deficient, such as the receipt of mail can not display unread mail, mail can not be sent in order to send the sequence of the orders and so on, I hope that we are interested in helping a lot of perfect, Have any good idea good suggestion to communicate with me more, welcome letter sn1985boy@sohu.com.