17. april 2001 - 13:33
Der er
8 kommentarer og
1 løsning
Webmail
Nogen der ved hvor jeg kan downloade et webmail script som er i asp.
Der skal være mulighed for, at logge ind påsin konto, læse/skrive mails, gerne med vedhæftet fil og andet godt
her er 2 en til at læse og en til at skrive mail, jeg gider ikke kode dem sammen for sølle 100 point.
<!--læse mail-->
Set Mailer = Server.CreateObject(\"SMTPsvg.Mailer\")
Mailer.RemoteHost = \"mail.domæne.dk\"
Mailer.FromName = \"navn\"
Mailer.FromAddress = \"email@domæne.dk\"
Mailer.AddRecipient Request.QueryString(\"nameto\"), Request.QueryString(\"addressto\")
Mailer.Subject = \"Emnet\"
Mailer.BodyText = Request.QueryString(\"txtmsg\")
Mailer.CharSet = 2
if not Mailer.SendMail then
Response.Write \" Mailing Failed... Error is: <br>\"
Response.Write Mailer.Response
else
Response.Write \" sent successfully...<p>\"
end if
Set Mailer = nothing
<!--læse mail-->
<html>
<head>
<title></title>
<head>
<body bgcolor=\"white\">
<blockquote>
<%
Server.ScriptTimeOut = 90000
function Subst (strValue, strOldValue, strNewValue)
intLoc = InStr(strValue, strOldValue)
While intLoc > 0
if intLoc > 1 then
if intLoc = Len(strValue) then
strValue = Left(strValue, intLoc-1) & strNewValue
else
strValue = Left(strValue, intLoc -1) & strNewValue & Right(strValue, Len(strValue)-(intLoc-Len(strOldValue)+1))
end if
else
strValue = strNewValue & Right(strValue, Len(strValue)-1)
end if
intLoc = InStr(strValue, strOldValue)
Wend
Subst = strValue
end function
function FixUpItems (strItem)
if strItem <> \"\" then
strItem = Subst(strItem, \"<\", \"<\")
strItem = Subst(strItem, \">\", \">\")
FixUpItems = strItem
else
FixUpItems = \"<br>\"
end if
end function
\'--- Shows a form for the user to fill in host, uid and pwd ---
sub ShowPopForm (strHostName, strUser, strPassword)
Response.Write \"<table border=0>\"
Response.Write \"<form action=\"\"AspPOP3.asp\"\" method=post>\"
Response.Write \"<tr><td>Enter POP3 Mail Host:<td><input type=text size=45 name=host value=\"\"\" & strHostName & \"\"\">\"
Response.Write \"<tr><td>Enter POP3 User Name:<td><input type=text size=45 name=uid value=\"\"\" & strUser & \"\"\">\"
Response.Write \"<tr><td>Enter POP3 Password:<td><input type=password size=45 name=pwd value=\"\"\" & strPassword & \"\"\">\"
Response.Write \"<input type=\"\"Submit\"\">\"
Response.Write \"</form>\"
Response.Write \"</table>\"
end sub
\'--- Get the list of all message headers and display the info to the client ---
sub ShowMessageList (strHost, strUid, strPwd)
Response.Write \"<b>Messages Currently On Server: \" & strHost & \"</b>\"
Set Mailer = Server.CreateObject(\"POP3svg.Mailer\")
Mailer.RemoteHost = strHost
Mailer.UserName = strUid
Mailer.Password = strPwd
if Mailer.GetPopHeaders then
Response.Write \"<br>Found \" & Mailer.MessageCount & \" messages on server.<p>\" & VbCrLf
Response.Write \"<table border=1>\" & VbCrLf
Response.Write \"<tr>\" & VbCrLf
Response.Write \"<td><b>\" & \"Msg #\" & \"<b></td>\" & VbCrLf
Response.Write \"<td><b>\" & \"Subject\" & \"<b></td>\" & VbCrLf
Response.Write \"<td><b>\" & \"Date\" & \"<b></td>\" & VbCrLf
Response.Write \"<td><b>\" & \"From\" & \"<b></td>\" & VbCrLf
Response.Write \"<td><b>\" & \"Size\" & \"<b></td>\" & VbCrLf
Response.Write \"<td><b>\" & \"Delete\" & \"<b></td>\" & VbCrLf
Response.Write \"</tr>\" & VbCrLf
varArray = Mailer.MessageInfo
if VarType(varArray) <> vbNull And IsEmpty(varArray) <> True then
ArrayLimit = UBound(varArray)
For I = 0 to ArrayLimit
Response.Write \"<tr>\"
strMsgNo = Trim(varArray(I)(0))
Randomize
intRndNo = Int(500 * Rnd)
Response.Write \"<td align=right>\" & strMsgNo & \"</td>\"
strSubject = varArray(I)(1)
if strSubject = \"\" then strSubject = \"(No Subject)\"
Response.Write \"<td align=left>\" & \"<a href=AspPOP3.asp?msgno=\" & strMsgNo & \"&rndno=\" & intRndNo & \">\" & FixUpItems (strSubject) & \"</a></td>\" & VbCrLf
Response.Write \"<td align=left>\" & varArray(I)(2) & \"</td>\" & VbCrLf
Response.Write \"<td align=left>\" & FixUpItems (varArray(I)(3)) & \"</td>\" & VbCrLf
Response.Write \"<td align=left>\" & varArray(I)(7) & \"</td>\"
Response.Write \"<td align=left>\" & \"<a href=AspPOP3.asp?deletemsg=\" & strMsgNo & \"&rndno=\" & intRndNo & \">Delete</a></td>\"
Response.Write \"</tr>\" & Chr(10) & Chr(13)
Next
else
Response.Write \"<tr><td colspan=10 align=center><b>No messages on server</b></tr>\"
end if
Response.Write \"</table><br>\"
Response.Write \"<a href=\"\"AspPOP3.asp?rndno=\" & intRndNo & \"\"\">Refresh</a>\"
else
Response.Write \"<p>Connection Failure. Check your mailhost, username and password.\"
end if
Response.Write \"</blockquote>\"
Set Mailer = nothing
end sub
\'--- Shows the text for one specific message ---
sub ShowMessage(strHost, strUid, strPwd, strMsgNo)
Response.Write \"<b>Message #\" & strMsgNo & \" follows:</b>\"
Set Mailer = Server.CreateObject(\"POP3svg.Mailer\")
\'--- Make sure that you\'ve got write permissions to the following directory ---
strMailBaseDir = \"e:\\webmail.wannafind.dk\\attach\"
Mailer.MailDirectory = strMailBaseDir
Mailer.RemoteHost = strHost
Mailer.UserName = strUid
Mailer.Password = strPwd
Mailer.OpenPop3
\'--- Log option for debug ---
\'Mailer.Pop3Log = \"\"&strMailBaseDir&\"pop3log.txt\"
Mailer.Retrieve strMsgNo
Mailer.ClosePop3
Response.Write \"<table border=1>\" & VbCrLf
Response.Write \"<tr><td width=\"\"20%\"\" align=right><b>\" & \"Msg ID:\" & \"<b></td><td>\" & FixUpItems(Mailer.MessageID) & \"</td></tr>\" & VbCrLf
Response.Write \"<tr><td width=\"\"20%\"\" align=right><b>\" & \"Date:\" & \"<b></td><td>\" & Mailer.Date & \"</td></tr>\" & VbCrLf
Response.Write \"<tr><td width=\"\"20%\"\" align=right><b>\" & \"Subject:\" & \"<b></td><td>\" & FixUpItems(Mailer.Subject) & \"</td></tr>\" & VbCrLf
Response.Write \"<tr><td width=\"\"20%\"\" align=right><b>\" & \"From:\" & \"<b></td><td>\" & Mailer.FromName & \" <\" & Mailer.FromAddress & \"></td></tr>\" & VbCrLf
strTemp = Mailer.GetHeaderField(\"Reply-To\")
if strTemp <> \"\" then
Response.Write \"<tr><td width=\"\"20%\"\" align=right><b>\" & \"Reply-To:\" & \"<b></td><td>\" & FixUpItems(strTemp) & \"</td></tr>\" & VbCrLf
end if
strTemp = Mailer.Recipients
if strTemp <> \"\" then
Response.Write \"<tr><td width=\"\"20%\"\" align=right><b>\" & \"To:\" & \"<b></td><td>\" & FixUpItems(strTemp) & \"</td></tr>\" & VbCrLf
end if
strTemp = Mailer.CC
if strTemp <> \"\" then
Response.Write \"<tr><td width=\"\"20%\"\" align=right><b>\" & \"CC:\" & \"<b></td><td>\" & FixUpItems(strTemp) & \"</td></tr>\" & VbCrLf
end if
Response.Write \"<tr><td width=\"\"20%\"\" align=right><b>\" & \"Attachments:\" & \"<b></td><td>\" & Mailer.AttachmentCount & \"</td></tr>\" & VbCrLf
Response.Write \"</table><pre><br>\" & VbCrLf
Response.Write FixUpItems(Mailer.BodyText) & VbCrLf
Response.Write \"</pre>\" & VbCrLf
if Mailer.AttachmentCount > 0 then
Response.Write \"<table border=1>\" & VbCrLf
Response.Write \"<tr><td>Attachment</td><td>ContentType</td><td>FileName</td><td>FileSize</td></tr>\" & VbCrLf
For intCount = 1 to Mailer.AttachmentCount
if Mailer.GetAttachmentInfo (intCount) then
Response.Write \"<tr><td>\" & intCount & \"</td><td>\" & Mailer.AttContentType & \"</td><td><a href=\"\"\" & Mailer.AttFileName & \"\"\">\" & Mailer.AttFileName & \"</a></td><td>\" & Mailer.AttFileSize & \"</td></tr>\" & VbCrLf
Mailer.SaveAttachment (intCount)
end if
Next
Response.Write \"</table>\" & VbCrLf
end if
Response.Write \"<br><a href=\"\"AspPOP3.asp?rndno=\"&Second(Now)&\"\"\">Back</a>\" & VbCrLf
Set Mailer = nothing
end sub
\'--- DELETE the message PERMANENTLY from the server ---
sub DeleteMessage (strHost, strUid, strPwd, strMsgNo)
Response.Write \"<b>Deleting Message #\" & strMsgNo & \" From Server</b><p>\"
Set Mailer = Server.CreateObject(\"POP3svg.Mailer\")
Mailer.RemoteHost = strHost
Mailer.UserName = strUid
Mailer.Password = strPwd
Mailer.OpenPop3
Mailer.Delete strMsgNo
Mailer.ClosePop3
ShowMessageList strHost, strUid, strPwd
Set Mailer = nothing
end sub
sub SavePOPVars
Session(\"host\") = Request.Form(\"host\")
Session(\"uid\") = Request.Form(\"uid\")
Session(\"pwd\") = Request.Form(\"pwd\")
end sub
\'--- Main code begins here
if Request.ServerVariables(\"REQUEST_METHOD\") = \"POST\" then
SavePOPVars
end if
strHost = Session(\"host\")
strUid = Session(\"uid\")
strPwd = Session(\"pwd\")
strMsgNo = Request.QueryString(\"msgno\")
strDeleteNo = Request.QueryString(\"deletemsg\")
if (strUid = \"\") or (strPwd = \"\") or (strHost = \"\") then
ShowPopForm strHost, strUid, strPwd
else
if (strMsgNo <> \"\") then
ShowMessage strHost, strUid, strPwd, strMsgNo
else
if (strDeleteNo <> \"\") then
DeleteMessage strHost, strUid, strPwd, strDeleteNo
else
ShowMessageList strHost, strUid, strPwd
end if
end if
end if
%>
</body>
</html>