|
 |
asp_web_howto thread: AW: Re: AW: Re: AW: How to do a sms system? URGENT!
Message #1 by "Marcel Hug" <hugmarcel@h...> on Tue, 7 Jan 2003 15:46:26 +0100
|
|
Hi,
sorry, but I am quite in a hurry at the moment, problem is as well that
I fly to vacation this evening. I am back on the 23.
Sorry for that.
Marcel
-----Urspr=FCngliche Nachricht-----
Von: Nikos [mailto:pappas@c...]
Gesendet: Dienstag, 7. Januar 2003 14:45
An: ASP Web HowTo
Betreff: [asp_web_howto] Re: AW: Re: AW: How to do a sms system? URGENT!
Hi Marcel
Thank you for the info
I don't need this for any project but I will try
to study it.
Thanks again
best regards
Nikos
At 05:46 =EC=EC 6/1/2003, you wrote:
>Well, this is the code.
>
>IN order to run it, you need a web component which provides the
>propertys and methods listed. In order to send an SMS message to a
>mailbox, you just
>Need an provider who offers a sms-to-mail gateway. Usually, ESMTP
>authorisation is required.
>
>This is the whole content of my global.asa file: Mails are stored in a
>database table, and then retrieved by global.asa when a user session
>times out. Hope this is of any help too you:
>
><SCRIPT LANGUAGE=3DVBScript RUNAT=3DServer>
>
>' Mailqueue handling example provided by Marcel A. Hug Informatik GmbH,
>Switzerland (www.huginfo.ch).
>' Please send advice for improvement to mhug@h...
>
>' Demonstrates sending of mails stored in Access table mailqueue when
>user or system ends ASP-session.
>' The session ends, when the session timeout fires, or when the user
>logs off (Session.Abandon).
>
>Sub Application_OnStart
>
> ' Application_OnEnd doesn't allow usage of Mappath method, that's
why
>we use a system variable
> Application("SessionDB") =3D
Server.Mappath("anywhere\anydb.mdb")
> Application("SessionLogfile") =3D Server.Mappath("Session.html")
>
> ' Application and session events are written to the Session.html
>logfile
> Dim objFSO, objFile
> Set objFSO =3D Server.CreateObject("Scripting.FileSystemObject")
>
> ' Session.html gets automatically deleted when size is about 1mb.
> if objFSO.FileExists(Application("SessionLogfile")) then
> Set f =3D objFSO.GetFile(Application("SessionLogfile"))
> if (f.size > 1000000) then
> f.Delete()
> end if
> end if
>
> ' The iusr_<host> account needs write privilege to the base
directory,
>so that Sesion.html can be written
> ' Nothing shall happen when the access rights are not set properly
>(Session.html is not written)
> On Error resume Next
> Set objFile =3D objFSO.OpenTextFile(Application("SessionLogfile"),
8,
>True)
> Set objFSO =3D Nothing
> objFile.WriteLine "<html>"
> objFile.WriteLine "<body>"
> objFile.WriteLine "<br><br>"
> objFile.WriteLine "-> Application started at " & Now()
> objFile.Close
> Set objFile =3D Nothing
> On Error Goto 0
>End Sub
>
>Sub Session_OnStart
> Application.Lock
>
> Dim objFSO, objFile
> Set objFSO =3D Server.CreateObject("Scripting.FileSystemObject")
>
> On Error resume Next
> Set objFile =3D objFSO.OpenTextFile(Application("SessionLogfile"),
8,
>True)
> Set objFSO =3D Nothing
> objFile.WriteLine "<br><br>"
> objFile.WriteLine "Session: " & Session.SessionID & " started at " &
>Now()
> objFile.Close
> Set objFile =3D Nothing
> On Error Goto 0
>
> Application.Unlock
>End Sub
>
>Sub Session_OnEnd
>
> ' The WebMail component sends all mails stored in table mailqueue
> Application.Lock
>
> Dim objFSO, objFile
> Set objFSO =3D Server.CreateObject("Scripting.FileSystemObject")
>
> On Error resume Next
> Set objFile =3D objFSO.OpenTextFile(Application("SessionLogfile"),
8,
>True)
> Set objFSO =3D Nothing
> objFile.WriteLine "<br>"
> objFile.WriteLine "Session: " & Session.SessionID & " ended at " &
>Now()
> On Error Goto 0
>
> ' Set the datasource to the mailqueue access database
> dim dsn, Conn
> dsn=3D"DBQ=3D" & Application("SessionDB") & ";Driver=3D{Microsoft
Access
>Driver (*.mdb)};"
> Set Conn =3D Server.CreateObject("ADODB.Connection")
> Conn.Open dsn
>
> ' The mailqueue table contains all mail properties which have been
>collected during a user session
> Set RSPMailqueue =3D Server.CreateObject("ADODB.Recordset")
> SQL =3D "Select * from Mailqueue where SMTPHost <> '' order by id"
>
> ' Loop through the mails
> RSPMailqueue.Open SQL, Conn, 3, 2
> Do While Not RSPMailqueue.eof
>
> ' Every second mail is sent only, when the previous mail could not
>be sent successfully, and when the
> ' mail attribute ApplyIfPrimaryHostDown is not set to true in the
>record
> if (RSPMailqueue("ApplyIfPrimaryHostDown") =3D true) then
> if (success =3D true) then
> success =3D false
>
> ' Delete the mail from the queue
> SQL =3D "DELETE from Mailqueue where id =3D " &
>trim(RSPMailqueue("Id"))
> Set RSPMailqueueDelete =3D Conn.Execute(SQL)
>
> ' Retrieve the next mail
> RSPMailqueue.movenext
> end if
> end if
>
> ' Now prepare the WebMailer
> set mailman =3D Server.CreateObject("WebMail.WebMailMan")
> mailman.UnlockComponent "scriptKey"
>
> mailman.SmtpHost =3D trim(RSPMailqueue("SMTPHost"))
> if (trim(RSPMailqueue("SMTPPort")) <> "") then
> mailman.SmtpPort =3D trim(RSPMailqueue("SMTPPort"))
> end if
>
> if (trim(RSPMailqueue("SMTPUsername")) <> "") then
> mailman.SmtpUsername =3D trim(RSPMailqueue("SMTPUsername"))
> end if
>
> if (trim(RSPMailqueue("SMTPPassword")) <> "") then
> mailman.SmtpPassword =3D trim(RSPMailqueue("SMTPPassword"))
> end if
>
> if (trim(RSPMailqueue("SMTPLoginDomain")) <> "") then
> mailman.SmtpLoginDomain =3D
trim(RSPMailqueue("SMTPLoginDomain"))
> end if
>
> if (trim(RSPMailqueue("SMTPAuthMethod")) <> "") then
> mailman.SmtpAuthMethod =3D trim(RSPMailqueue("SMTPAuthMethod"))
> end if
>
> mailman.DefaultCharset =3D "iso-8859-5"
> set email =3D Server.CreateObject("WebMail.WebEmail")
>
> email.FromName =3D trim(RSPMailqueue("FromName"))
> email.FromAddress =3D lcase(trim(RSPMailqueue("FromAdress")))
> email.ReplyTo =3D lcase(trim(RSPMailqueue("ReplyTo")))
>
> if (trim(RSPMailqueue("AddTo")) <> "") then
> email.AddMultipleTo lcase(trim(RSPMailqueue("AddTo")))
> end if
>
> if (trim(RSPMailqueue("CCTo")) <> "") then
> email.AddMultipleCC lcase(trim(RSPMailqueue("CCTo")))
> end if
>
> if (trim(RSPMailqueue("BccTo")) <> "") then
> email.AddMultipleBcc lcase(trim(RSPMailqueue("BccTo")))
> end if
>
> if (trim(RSPMailqueue("Subject")) <> "") then
> email.Subject =3D trim(RSPMailqueue("Subject"))
> end if
>
> if (trim(RSPMailqueue("Body")) <> "") then
> email.Body =3D trim(RSPMailqueue("Body"))
> end if
>
> ' Verify the SMTP connection in advance
> sendmail =3D false
> if (mailman.VerifySMTPLogin() =3D 1) then
> sendmail =3D true
> end if
>
> ' Send the email
> success =3D false
> if (sendmail =3D true) then
> if mailman.SendEmail(email) then
> success =3D true
>
> On Error resume Next
> objFile.WriteLine "<br>"
> objFile.WriteLine "Session: " & Session.SessionID & ": Mail "
&
>trim(RSPMailqueue("Id")) & " successfully sent to " &
>trim(RSPMailqueue("AddTo")) & " at " & Now()
> On Error Goto 0
> end if
> end if
>
> Set email =3D Nothing
> Set mailman =3D Nothing
>
> ' Delete the mail from the queue
> SQL =3D "DELETE from Mailqueue where id =3D " &
trim(RSPMailqueue("Id"))
> Set RSPMailqueueDelete =3D Conn.Execute(SQL)
>
> if not RSPMailqueue.eof then
> RSPMailqueue.movenext
> end if
> Loop
>
> RSPMailqueue.close
> Set RSPMailqueue =3D Nothing
>
> Conn.close
> set Conn =3D nothing
>
> On Error Resume Next
> objFile.Close
> Set objFile =3D Nothing
> On Error Goto 0
>
> Application.Unlock
>End Sub
>
>Sub Application_OnEnd
>
> ' This happens (normally) when the www publishing service is being
>shut down
> Dim objFSO, objFile
> Set objFSO =3D Server.CreateObject("Scripting.FileSystemObject")
>
> On Error resume Next
> Set objFile =3D objFSO.OpenTextFile(Application("SessionLogfile"),
8,
>True)
> Set objFSO =3D Nothing
> objFile.WriteLine "<br><br>"
> objFile.WriteLine "</body>"
> objFile.WriteLine "</html>"
> objFile.WriteLine "<- Application ended at " & Now()
> objFile.Close
> Set objFile =3D Nothing
> On Error Goto 0
>End Sub
>
></SCRIPT>
>
>-----Urspr=FCngliche Nachricht-----
>Von: Nikos [mailto:pappas@c...]
>Gesendet: Montag, 6. Januar 2003 16:14
>An: ASP Web HowTo
>Betreff: [asp_web_howto] Re: AW: How to do a sms system? URGENT!
>
>Hi
>I would like to see this code as well please
>Best regards
>Nikos
>At 11:24 =F0=EC 6/1/2003, you wrote:
> >Hi
> >
> >I am the programmer of Reservation 2.0 ASP, a popular Reservation
>System
> >over the internet. Look at it under www.huginfo.ch -> Reservation 2.0
> >English. You can login with Admin/Admin. You can send SMS / Mail
> >whenever data changes. In the program, you go to program
settings->Mail
> >Notification Configuration and then click on one of the SMS letter
> >symbols, preferably of host nr. 2.
> >
> >If you like it I can send you the complete ASP code doing that. The
>code
> >is fairly easy to understand.
> >
> >Marcel
> >
> >-----Urspr=FCngliche Nachricht-----
> >Von: Crystal Lilian [mailto:crystal_lilian@h...]
> >Gesendet: Montag, 6. Januar 2003 10:16
> >An: ASP Web HowTo
> >Betreff: [asp_web_howto] How to do a sms system? URGENT!
> >
> >hi!
> >i m a college student ..and I have to finish my final project with
this
> >title...........sms (short messages services)
> >
> >does anyone know about the way to develop this popular system...
> >Do you try it before?
> >or do you have the coding.......
> >
> >URGENT!......Please help.....
> >
> >
> >_________________________________________________________________
> >The new MSN 8: smart spam protection and 2 months FREE*
> >http://join.msn.com/?page=3Dfeatures/junkmail
> >
> >
> >
>
>
>
>
|
|
 |