WaBis

walter.bislins.ch

Datei: xmail.asp

Inhalt der Datei: ./asp/xmail/xmail.asp
<% Option Explicit %>
<!--#include file="xmailutil.inc" -->
<!--#include file="xmail.inc" -->
<%
dim mailer, comps, i

function Status(c)
  if c.IsAvailable then
    Status = "ja"
  else
    Status = "nein"
  end if
end function

function sel(val,opt)
  if val = opt then
    sel = "selected"
  else
    sel = ""
  end if
end function

function chck(val,opt)
  if val = opt then
    chck = "checked"
  else
    chck = ""
  end if
end function

set mailer = new CxMail
comps = mailer.SupportedComponents
%>

<html><head>
<title>CxMail Test</title>
<style type="text/css">
<!--
table.tab { border:1px solid black; text-align:left; }
table.tab th, table.tab td { padding:0 0.5em; }
table.tab th { background-color:#ddd; }
input, option, textarea, select { font-family:Verdana; }
div.description { font-size:smaller; }
.error { background-color:#ff8; }
table { border-collapse:collapse; }
td { vertical-align:top; }
table.layout { padding:0; margin:0; }
td.layoutcell { border:1px solid gray; padding:0; margin:0; }
table.fieldset { width:100%; }
td.label { text-align:right; font-weight:bold; padding-right:0.5em; width:160px; }
td.field { padding:0 0 0.5em 0; }
td.ifield { padding:0 0 0.5em 0; }
td.ifield td.field { padding:0; }
td.ifield td.layoutcell { border:none; }
table.align { padding:0; margin:0; }
table.align td { padding:0 0.5em 0 0; margin:0; }
-->
</style>
</head>
<body>
<h1>CxMail Test</h1>
<p>
Folgende Mail-Komponenten sind auf diesem Server installiert:
</p>
<table class="tab">
<tr>
  <th>Name</th>
  <th>Verfügbar?</th>
  <th>Dokumentation</th>
</tr>

<%
for i = 0 to UBound(comps)
%>
<tr>
  <td><%=comps(i).Name%></td>
  <td><%=Status(comps(i))%></td>
  <td><a href="<%=comps(i).DocUrl%>"><%=comps(i).DocUrl%></a></td>
</tr>
<%
next
%>
</table>
<%

dim smtpHost, compName, fromAddr, fromName, toAddr, queue, pickupFolder, subject, body, username, password
smtpHost = "smtp.domain.ch"
compName = ""
queue = true
pickupFolder = "c:\inetpub\mailroot\pickup"
fromAddr = "xmail@bislins.ch"
fromName = "Waltis Website"
toAddr = ""
subject = "CxMail Test"
body = ""
username = ""
password = ""

if Request.Form("btnSend") = "" then

%>
<p>Wähle eine Mail-Komponenete und ein MailDelivery und setze eine Testmail ab:</p>

<form action="xmail.asp" method="post">
<table class="fieldset"><tr>
<td class="label">MailComponent</td><td class="field"><select name="edtMailComponent" size="1">
<option value="" <%=sel(compName,"")%>>Auto choose</option>
<option value="CDOSYS" <%=sel(compName,"CDOSYS")%>>CDOSYS</option>
<option value="Persits" <%=sel(compName,"Persits")%>>Persits</option>
</select></td>
</tr><tr>
<td class="label">MailDelivery</td><td class="field"><table class="align"><tr>
<td width="50%"><input type="radio" name="edtQueue" value="false" <%=chck(queue,false)%>>Send&nbsp;</td>
<td width="50%"><input type="radio" name="edtQueue" value="true" <%=chck(queue,true)%>>Queue&nbsp;</td>
</tr></table>
<div class="description">Use Queue when ever possible!</div></td>
</tr><tr>
<td class="label">MailHost</td><td class="field"><input name="edtMailHost" type="text" value="<%=smtpHost%>"><div class="description">If MailDelivery = Send: MailHost is used to connect to a Mail-Server (e.g. smtp.domain.com)</div></td>
</tr><tr>
<td class="label">MailPickupFolder</td><td class="field"><input name="edtMailPickupFolder" type="text" value="<%=pickupFolder%>"><div class="description">If MailDelivery = Queue: PickupFolder is used as the mail output folder (Default = c:\inetpub\mailroot\pickup)</div></td>
</tr><tr>
<td class="label">Username</td><td class="field"><input name="edtUsername" type="text" value="<%=username%>"><div class="description">If MailHost needs authentication supplie username and password</div></td>
</tr><tr>
<td class="label">Password</td><td class="field"><input name="edtPassword" type="text" value="<%=password%>"></td>
</tr><tr>
<td class="label">From</td><td class="field"><input name="edtFrom" type="text" value="<%=fromAddr%>"></td>
</tr><tr>
<td class="label">FromName</td><td class="field"><input name="edtFromName" type="text" value="<%=fromName%>"></td>
</tr><tr>
<td class="label">To</td><td class="field"><input name="edtTo" type="text" value="<%=toAddr%>"></td>
</tr><tr>
<td class="label">&nbsp;</td>
<td class="field"><input type="submit" name="btnSend" value="Send"></td>
</tr></table>
</form>
<%
else ' button send clicked

compName = Request.Form("edtMailComponent")
queue = Request.Form("edtQueue") = "true"
smtpHost = Request.Form("edtMailHost")
pickupFolder = Request.Form("edtMailPickupFolder")
username = Request.Form("edtUsername")
password = Request.Form("edtPassword")
fromAddr  = Request.Form("edtFrom")
fromName = Request.Form("edtFromName")
toAddr = Request.Form("edtTo")
body = "MailComponent = " & compName & " (empty = auto choose)" & vbCRLF
body = body & "Host = " & smtpHost & vbCRLF
body = body & "Queue = " & queue & vbCRLF
body = body & "PicupFolder = " & pickupFolder & vbCRLF
body = body & "From = " & fromAddr & vbCRLF
body = body & "To = " & toAddr & vbCRLF

stop
dim ok
ok = false
on error resume next
if mailer.SelectComponent( smtpHost, compName ) then
  mailer.Queue = queue
  mailer.PickupFolder = pickupFolder
  mailer.UserName = username
  mailer.Password = password
  mailer.FromAddr = fromAddr
  mailer.FromName = fromName
  mailer.AddTo toAddr, ""
  mailer.Subject = subject
  mailer.Body = body
  mailer.Send
  if Err = 0 then ok = true
end if

if ok then
%>
  <p>Test-Mail versandt! Ob erfolgreich oder nicht kann nur durch einen Blick ins Postfach des Empfängers herausgefunden werden.</p>
<%
else
%>
  <p>Test-Mail konnte nicht versand werden!</p>
<%
  if Err <> 0 then Response.Write "<p>Error = " & Err.Description & "</p>"
end if
%>
  <p><a href="xmail.asp">Erneuter Versuch</a></p>
<%
end if
%>
</body>
</html>


Weitere Infos zur Seite
Erzeugt Dienstag, 18. Oktober 2011
von wabis
Zum Seitenanfang
Geändert Montag, 12. Oktober 2015
von wabis