"Ricki Korsholm Knudsen" <ricki@korsholm.net> skrev i en meddelelse
news:BCHC6.1263$UH.473904@news101.telia.com...
> Objectmodellen CDONTS indeholder objektet session, der giver mulighed for
at
> logge på en SMTP server via LogonSMTP. Dette gælder kun en lokal
> mailserver,
> er det muligt at gøre nogen lignende, og komme i kontakt med mails på en
> ekstern mailserver?
Du kan ikke læse mails vha. SMTP, det kan kun bruges til at sende mails.
Hvis læse dine POP3 mails, så kan du gøre det med komponentet JMail.POP3
(hvis du har adgang til det på web-serveren), her har du et script som gør
dig i stand til at læse dine pop3 mails via en asp-side:
Det er i øvrigt ikke helt rigtigt det du skriver at man kun kan bruge en
lokal SMTP-server til at sende via når man bruger CDONTS, LogonSMTP eller
for den sags skyld JMail.SMTPMail.
Men her har i hvert fald koden til JMail.POP3:
<html>
<head>
<title>w3 JMail POP3 Demo Script</title>
<head>
<body bgcolor="white">
<blockquote>
<h2>w3 JMail POP3 Demo Script</h2>
<% if request.form = "" then %>
<form method=post>
<table>
<tr>
<td>
Server:
</td>
<td>
<input type=text name=servername value="">
</td>
</tr>
<tr>
<td>
Username:
</td>
<td>
<input type=text name=username value="">
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type=password name=password>
</td>
</tr>
</table>
<input type=submit value=Login...>
</form>
<%
else
Set pop3 = Server.CreateObject("JMail.POP3")
pop3.Connect request.form("username"), request.form("password"),
request.form("servername")
Response.Write( "You have " & pop3.count & " emails in your
mailbox!<br><br>" )
For h = 1 to pop3.count
response.write "<hr><b>Besked " & h & "</b><br>"
'if pop3.count > 0 then
Set msg = pop3.Messages.item(h)
' Note the first element of this array is 1,
' since the POP3 server starts counting at 1
ReTo = ""
ReCC = ""
Set Recipients = msg.Recipients
separator = ", "
' We now need to get all the recipients,
' both normal and Carbon Copy (CC) recipients
' and store them in a variabel
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
' This function iterates through the Attachments object,
' and saves the attachment to the server's disk.
' It also returns a nicely formatted string with a
' link to the attachment.
if False then
'Function getAttachments()
Set Attachments = msg.Attachments
separator = ", "
for i = 0 To Attachments.Count - 1
if i = Attachments.Count - 1 then
separator = ""
end if
Set at = Attachments(i)
at.SaveToFile(""&Request.ServerVariables("APPL_PHYSICAL_PATH")&"\log\"&at.Na
me&"")
getAttachments = getAttachments & "<a href=""/log/" &_
at.Name &""">" & at.Name & "(" & at.Size & " bytes)" &_
"</a>" & separator
next
'End Function
end if
Response.Write "<table>" + vbCrLf
Response.Write "<tr><td>Subject</td><td>"&msg.Subject&"</td></tr>" +
vbCrLf
Response.Write "<tr><td>From</td><td>"&msg.FromName&"</td></tr>" + vbCrLf
Response.Write "<tr><td>Recipients To</td><td>"&ReTO&"</td></tr>" + vbCrLf
Response.Write "<tr><td>Recipients CC</td><td>"&ReCC&"</td></tr>" + vbCrLf
Response.Write "<tr><td>Attachments</td><td>"&getAttachments&"</td></tr>"
+ vbCrLf
Response.Write "<tr><td valign=top>Body</td><td
valign=top><pre>"&msg.Body&"</pre></td></tr>" + vbCrLf
Response.Write "</table>" + vbCrLf
'end if
Next
response.write "<hr>"
pop3.Disconnect
Set pop3 = nothing
end if
%>
</blockquote>
</body>
</html>
Mvh. Christoffer Thygesen
homepage:
http://cht.dk
e-mail: cht@cht.dk