29. januar 2002 - 19:33
#7
Prøv:
<%
' *** SMTP Mail komponent valg ***
' 0 = JMail
' 1 = ASPMail
intMailer = 0
strSMTP = "mail.snuseren.dk" ' SMTP server
strAfs = "postmaster@snuseren.dk" ' En gyldig POP3 konto
Function Wrap(ByVal Text, ByVal WrapChar, ByVal WrapAt)
' *****************************************************************************************************
' * WordWrap v1.2 - WordWraps a string off as near as possible to the specified max character amount *
' * By Thomas Daugaard, December 11th, 2000. *
' * *
' * Arguments: Text : The string to wordwrap *
' * WrapChar : A string specifying how/with what to wrap the string. Default is <br> *
' * WrapAt : Numeric value specifying the maximum amount of characters allowed in a *
' * string. Wraps backwards in the string to ensure that the max value is meet. *
' * *
' * Note: Arguments are passed By Value, not reference. *
' *****************************************************************************************************
Text = Trim(Text)
If Len(Text) =< WrapAt Or Len(Text) = 0 Or InStr(Text, " ") = 0 Then Wrap = "" & Text: Exit Function
If Len(WrapChar) = 0 Then WrapChar = "<br>"
Do
If Len(Text) < WrapAt Then strFinal = strFinal & Text: Exit Do
strPart = Left(Text, WrapAt): intOff = WrapAt
If Not Right(strPart, 1) = " " Then
intOff = InStrRev(strPart, " ")
If intOff = 0 Then intOff = InStr(Text, WrapAt, " ")
If intOff = 0 Then strPart = Text
End If
strPart = Left(Text, intOff)
Text = Right(Text, Len(Text) - Len(strPart))
strFinal = strFinal & strPart & WrapChar
Loop
Wrap = strFinal
End Function
strNummer = Request("nummer")
strFra = Request("fra")
strBesked = Request("besked")
If Len(strNummer) > 0 And Len(strFra) > 0 And Len(strBesked) > 0 Then
strTeleDK = "@sms.tdm.dk"
strSonofon = "@note.sonofon.dk"
strTelia = "@gsm1800.telia.dk"
strMobilix = "@sms.mobilix.dk"
bolValid = False
If Len(strNummer) = 8 And IsNumeric(strNummer) Then
If CInt(Left(strNummer, 4)) > 2010 Then
If CInt(Left(strNummer, 4)) => 2010 And CInt(Left(strNummer, 4)) =< 2059 Then strDom = strTeleDK
If CInt(Left(strNummer, 4)) => 2060 And CInt(Left(strNummer, 4)) =< 2099 Then strDom = strSonofon
If CInt(Left(strNummer, 4)) => 2110 And CInt(Left(strNummer, 4)) =< 2199 Then strDom = strTeleDK
If CInt(Left(strNummer, 4)) => 2210 And CInt(Left(strNummer, 4)) =< 2299 Then strDom = strSonofon
If CInt(Left(strNummer, 4)) => 2310 And CInt(Left(strNummer, 4)) =< 2399 Then strDom = strTeleDK
If CInt(Left(strNummer, 4)) => 2610 And CInt(Left(strNummer, 4)) =< 2699 Then strDom = strMobilix
If CInt(Left(strNummer, 4)) => 2810 And CInt(Left(strNummer, 4)) =< 2899 Then strDom = strTelia
If CInt(Left(strNummer, 4)) => 3010 And CInt(Left(strNummer, 4)) =< 3689 Then strDom = strTeleDK
If CInt(Left(strNummer, 4)) => 3690 And CInt(Left(strNummer, 4)) =< 3309 Then strDom = strMobilix
If CInt(Left(strNummer, 4)) => 3810 And CInt(Left(strNummer, 4)) =< 4049 Then strDom = strTeleDK
If CInt(Left(strNummer, 4)) => 4050 And CInt(Left(strNummer, 4)) =< 4099 Then strDom = strSonofon
If CInt(Left(strNummer, 4)) => 4320 And CInt(Left(strNummer, 4)) =< 4679 Then strDom = strTeleDK
If CInt(Left(strNummer, 4)) => 4690 And CInt(Left(strNummer, 4)) =< 4709 Then strDom = strMobilix
If CInt(Left(strNummer, 4)) => 4710 And CInt(Left(strNummer, 4)) =< 4979 Then strDom = strTeleDK
If CInt(Left(strNummer, 4)) = 6910 Or CInt(Left(strNummer, 4)) = 6911 Then strDom = strMobilix
If CInt(Left(strNummer, 4)) = 6912 Or CInt(Left(strNummer, 4)) = 6966 Then strDom = strMobilix
If CInt(Left(strNummer, 4)) => 6960 And CInt(Left(strNummer, 4)) =< 6964 Then strDom = strMobilix
If CInt(Left(strNummer, 4)) = 6969 Or CInt(Left(strNummer, 4)) = 6996 Then strDom = strMobilix
If CInt(Left(strNummer, 4)) => 6980 And CInt(Left(strNummer, 4)) =< 6989 Then strDom = strMobilix
If strDom > "" Then
strFra = "(" & strFra & ") "
intSubtract = Len(strFra) + Len(srtAfs) + 24
intMsgSize = (160 - intSubtract)
If intMailer = 0 Then
Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ServerAddress = strSMTP
JMail.Sender = strAfs
JMail.AddRecipient (strNummer & strDom)
Else
Set ASPMail = Server.CreateObject("SMTPsvg.Mailer")
ASPMail.RemoteHost = strSMTP
ASPMail.FromAddress = strAfs
ASPMail.AddRecipient "", (strNummer & strDom)
End If
If Len(strBesked) > intMsgSize then
strWrapped = Split(Wrap(strBesked, "|", intMsgSize), "|")
For Index = 0 To UBound(strWrapped)
Select Case intMailer
Case 0: JMail.Body = strFra & strWrapped(Index): JMail.Execute
Case 1: ASPMail.BodyText = strFra & strWrapped(Index): ASPMail.SendMail
End Select
Next
intMsgSize = UBound(strWrapped) + 1
Else
Select Case intMailer
Case 0: JMail.Body = strFra & strBesked: JMail.Execute
Case 1: ASPMail.BodyText = strFra & strBesked: ASPMail.SendMail
End Select
intMsgSize = 1
End If
Set JMail = Nothing
bolValid = True
Select Case (intMsgSize > 1)
Case True: strSendt = "<font face='Tahoma' size=2 color=#008000>Din besked blev sendt af <b>" & intMsgSize & "</b> SMS´er til <b>" & strNummer & "</b>.</font>"
Case False: strSendt = "<font face='Tahoma' size=2 color=#008000>Din besked blev sendt til <b>" & strNummer & "</b>!</font>"
End Select
Else
strSendt = "<font face='Tahoma' size=2 color=#800000>Beskeden kunne ikke sendes da det indtastede tlf.<br>nummer ikke er et gyldigt mobil nummer!</font>"
End If
End If
End If
End If
%>
<html>
<head>
<title>Send SMS</title>
<script language="JavaScript">
<!--
function showleft() {
document.frmSms.count.value=800-(document.frmSms.besked.value.length+document.frmSms.fra.value.length);
}
function checklength() {
if (document.frmSms.besked.value.length+document.frmSms.fra.value.length > 800) {
alert("Din besked må max. være på 800 tegn!");
document.frmSms.besked.focus();
return (false);
} else if (document.frmSms.nummer.value.length !=8) {
alert("Du skal skrive et gyldigt 8-cifret tlf. nummer!");
document.frmSms.nummer.focus();
return (false);
} else if (document.frmSms.fra.value.length == 0) {
alert("Du skal skrive et afsender navn/tlf. nummer!");
document.frmSms.fra.focus();
return (false);
}
return (true)
}
-->
</script>
</head>
<body>
<center>
<form method="post" action="default.asp" name="frmSms" onsubmit="return checklength();">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
<table border=0 cellspacing=0 cellpadding=0>
<tr>
<td valign="top" align="left"><input type="text" name="nummer" value="Nummer" size=8 maxlength=8 style="font-family: tahoma; size: 8pt;" value="<%=strNummer%>"></td>
<td valign="top" align="left"><input type="text" name="fra" value="Afsender" size=10 style="font-family: tahoma; size: 8pt;" onkeydown="showleft();" value="<%=strFra%>"></td>
</tr>
<tr>
<td valign="top" align="center" colspan=4><textarea rows=5 name="besked" value="Din besked..." border=0 onkeydown="showleft();" style="font-family: tahoma; size: 8pt; width: 145px;"><%=strBesked%></textarea>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" align="center">
<input type="submit" value="Send" style="size: 8pt; color: #008000; font-weight: 700;">
<input type="text" name="count" value="800" style="width: 28px;" readonly>
</tr>
</tr>
</table>
<%=strSendt%>
</form>
</center>
</body>
</html>
//Snuseren.dk