Initial Commit Update Telerik
This commit is contained in:
92
LPWeb20/Klassen/RandomKeyGenerator.vb
Normal file
92
LPWeb20/Klassen/RandomKeyGenerator.vb
Normal file
@@ -0,0 +1,92 @@
|
||||
Option Strict On
|
||||
Imports System.Text
|
||||
''' <date>27072005</date><time>070339</time>
|
||||
''' <type>class</type>
|
||||
''' <summary>
|
||||
''' REQUIRES PROPERTIES: KeyLetters, KeyNumbers, MaxChars
|
||||
''' </summary>
|
||||
Public Class RandomKeyGenerator
|
||||
Dim Key_Letters As String
|
||||
Dim Key_Numbers As String
|
||||
Dim Key_Chars As Integer
|
||||
Dim LettersArray As Char()
|
||||
Dim NumbersArray As Char()
|
||||
|
||||
''' <date>27072005</date><time>071924</time>
|
||||
''' <type>property</type>
|
||||
''' <summary>
|
||||
''' WRITE ONLY PROPERTY. HAS TO BE SET BEFORE CALLING GENERATE()
|
||||
''' </summary>
|
||||
Protected Friend WriteOnly Property KeyLetters() As String
|
||||
Set(ByVal Value As String)
|
||||
Key_Letters = Value
|
||||
End Set
|
||||
End Property
|
||||
''' <date>27072005</date><time>071924</time>
|
||||
''' <type>property</type>
|
||||
''' <summary>
|
||||
''' WRITE ONLY PROPERTY. HAS TO BE SET BEFORE CALLING GENERATE()
|
||||
''' </summary>
|
||||
Protected Friend WriteOnly Property KeyNumbers() As String
|
||||
Set(ByVal Value As String)
|
||||
Key_Numbers = Value
|
||||
End Set
|
||||
End Property
|
||||
''' <date>27072005</date><time>071924</time>
|
||||
''' <type>property</type>
|
||||
''' <summary>
|
||||
''' WRITE ONLY PROPERTY. HAS TO BE SET BEFORE CALLING GENERATE()
|
||||
''' </summary>
|
||||
Protected Friend WriteOnly Property KeyChars() As Integer
|
||||
Set(ByVal Value As Integer)
|
||||
Key_Chars = Value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
''' <date>27072005</date><time>072344</time>
|
||||
''' <type>function</type>
|
||||
''' <summary>
|
||||
''' GENERATES A RANDOM STRING OF LETTERS AND NUMBERS. LETTERS CAN BE RANDOMLY CAPITAL OR SMALL.
|
||||
''' </summary>
|
||||
''' <returns type="String">RETURNS THE RANDOMLY GENERATED KEY</returns>
|
||||
Function Generate() As String
|
||||
Dim i_key As Integer
|
||||
Dim Random1 As Single
|
||||
Dim arrIndex As Int16
|
||||
Dim sb As New StringBuilder
|
||||
Dim RandomLetter As String
|
||||
|
||||
''' CONVERT LettersArray & NumbersArray TO CHARACTR ARRAYS
|
||||
LettersArray = Key_Letters.ToCharArray
|
||||
NumbersArray = Key_Numbers.ToCharArray
|
||||
|
||||
For i_key = 1 To Key_Chars
|
||||
''' START THE CLOCK - LAITH - 27/07/2005 18:01:18 -
|
||||
Randomize()
|
||||
Random1 = Rnd()
|
||||
arrIndex = -1
|
||||
''' IF THE VALUE IS AN EVEN NUMBER WE GENERATE A LETTER, OTHERWISE WE GENERATE A NUMBER - LAITH - 27/07/2005 18:02:55 -
|
||||
''' THE NUMBER '111' WAS RANDOMLY CHOSEN. ANY NUMBER WILL DO, WE JUST NEED TO BRING THE VALUE ABOVE '0' - LAITH - 27/07/2005 18:40:48 -
|
||||
If (CType(Random1 * 111, Integer)) Mod 2 = 0 Then
|
||||
''' GENERATE A RANDOM LOCATION IN THE LETTERS CHARACTER ARRAY - LAITH - 27/07/2005 18:47:44 -
|
||||
Do While arrIndex < 0
|
||||
arrIndex = Convert.ToInt16(LettersArray.GetUpperBound(0) * Random1)
|
||||
Loop
|
||||
RandomLetter = LettersArray(arrIndex)
|
||||
''' CREATE ANOTHER RANDOM NUMBER. IF IT IS ODD, WE CAPITALIZE THE LETTER - LAITH - 27/07/2005 18:55:59 -
|
||||
If (CType(arrIndex * Random1 * 99, Integer)) Mod 2 <> 0 Then
|
||||
RandomLetter = LettersArray(arrIndex).ToString
|
||||
RandomLetter = RandomLetter.ToUpper
|
||||
End If
|
||||
sb.Append(RandomLetter)
|
||||
Else
|
||||
''' GENERATE A RANDOM LOCATION IN THE NUMBERS CHARACTER ARRAY - LAITH - 27/07/2005 18:47:44 -
|
||||
Do While arrIndex < 0
|
||||
arrIndex = Convert.ToInt16(NumbersArray.GetUpperBound(0) * Random1)
|
||||
Loop
|
||||
sb.Append(NumbersArray(arrIndex))
|
||||
End If
|
||||
Next
|
||||
Return sb.ToString
|
||||
End Function
|
||||
End Class
|
||||
206
LPWeb20/Klassen/clsSendMail.vb
Normal file
206
LPWeb20/Klassen/clsSendMail.vb
Normal file
@@ -0,0 +1,206 @@
|
||||
Imports System.Net.Mail
|
||||
Imports System.Web.Configuration
|
||||
Imports System.Net
|
||||
Public Class clsSendMail
|
||||
|
||||
|
||||
Public Shared Function SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String) As Boolean
|
||||
|
||||
If WebConfigurationManager.AppSettings("smtpserver") = "msscript1.webland.ch" Then
|
||||
Dim mailer As Object
|
||||
mailer = CreateObject("SMTPsvg.Mailer")
|
||||
mailer.FromName = WebConfigurationManager.AppSettings("NameAbsender")
|
||||
mailer.FromAddress = WebConfigurationManager.AppSettings("MailAbsender")
|
||||
mailer.RemoteHost = WebConfigurationManager.AppSettings("smtpserver")
|
||||
mailer.AddRecipient("", recepient)
|
||||
mailer.ContentType = "text/html"
|
||||
mailer.Subject = subject
|
||||
mailer.BodyText = body
|
||||
If mailer.SendMail Then
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Exit Function
|
||||
End If
|
||||
|
||||
|
||||
Dim ConfigFrom As String
|
||||
ConfigFrom = WebConfigurationManager.AppSettings("MailAbsender")
|
||||
' Instantiate a new instance of MailMessage
|
||||
Dim mMailMessage As New MailMessage()
|
||||
|
||||
' Set the sender address of the mail message
|
||||
If from = "" Then
|
||||
mMailMessage.From = New MailAddress(ConfigFrom)
|
||||
Else
|
||||
mMailMessage.From = New MailAddress(from)
|
||||
End If
|
||||
' Set the recepient address of the mail message
|
||||
mMailMessage.To.Add(New MailAddress(recepient))
|
||||
|
||||
' Check if the bcc value is nothing or an empty string
|
||||
If Not bcc Is Nothing And bcc <> String.Empty Then
|
||||
' Set the Bcc address of the mail message
|
||||
mMailMessage.Bcc.Add(New MailAddress(bcc))
|
||||
End If
|
||||
|
||||
' Check if the cc value is nothing or an empty value
|
||||
If Not cc Is Nothing And cc <> String.Empty Then
|
||||
' Set the CC address of the mail message
|
||||
mMailMessage.CC.Add(New MailAddress(cc))
|
||||
End If
|
||||
|
||||
' Set the subject of the mail message
|
||||
mMailMessage.Subject = subject
|
||||
' Set the body of the mail message
|
||||
mMailMessage.Body = body
|
||||
|
||||
' Set the format of the mail message body as HTML
|
||||
mMailMessage.IsBodyHtml = True
|
||||
' Set the priority of the mail message to normal
|
||||
mMailMessage.Priority = MailPriority.Normal
|
||||
|
||||
' Instantiate a new instance of SmtpClient
|
||||
Dim mSmtpClient As New SmtpClient()
|
||||
' Send the mail message
|
||||
Try
|
||||
mSmtpClient.Send(mMailMessage)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Return False
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Sub Send()
|
||||
|
||||
|
||||
Const ToAddress As String = "info@shub.ch"
|
||||
|
||||
'(1) Create the MailMessage instance
|
||||
Dim mm As New MailMessage("stefan.hutter@stefan-hutter.ch", "info@shub.ch")
|
||||
|
||||
'(2) Assign the MailMessage's properties
|
||||
mm.Subject = "Hallo"
|
||||
mm.Body = "Ich bin ein Test"
|
||||
mm.IsBodyHtml = False
|
||||
|
||||
'(3) Create the SmtpClient object
|
||||
Dim smtp As New SmtpClient
|
||||
|
||||
'(4) Send the MailMessage (will use the Web.config settings)
|
||||
smtp.Send(mm)
|
||||
Exit Sub
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
'Imports System.Net.Mail
|
||||
'Imports System.Web.Configuration
|
||||
'Imports System.Net
|
||||
'Public Class clsSendMail
|
||||
|
||||
|
||||
' Public Shared Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)
|
||||
' Dim ConfigFrom As String
|
||||
' ConfigFrom = WebConfigurationManager.AppSettings("MailAbsender")
|
||||
|
||||
' ' Instantiate a new instance of MailMessage
|
||||
' Dim mMailMessage As New MailMessage()
|
||||
|
||||
|
||||
|
||||
' ' Set the sender address of the mail message
|
||||
' If from = "" Then
|
||||
' mMailMessage.From = New MailAddress(ConfigFrom)
|
||||
' Else
|
||||
' mMailMessage.From = New MailAddress(from)
|
||||
' End If
|
||||
' ' Set the recepient address of the mail message
|
||||
' mMailMessage.To.Add(New MailAddress(recepient))
|
||||
|
||||
' ' Check if the bcc value is nothing or an empty string
|
||||
' If Not bcc Is Nothing And bcc <> String.Empty Then
|
||||
' ' Set the Bcc address of the mail message
|
||||
' mMailMessage.Bcc.Add(New MailAddress(bcc))
|
||||
' End If
|
||||
|
||||
' ' Check if the cc value is nothing or an empty value
|
||||
' If Not cc Is Nothing And cc <> String.Empty Then
|
||||
' ' Set the CC address of the mail message
|
||||
' mMailMessage.CC.Add(New MailAddress(cc))
|
||||
' End If
|
||||
|
||||
' ' Set the subject of the mail message
|
||||
' mMailMessage.Subject = subject
|
||||
' ' Set the body of the mail message
|
||||
' mMailMessage.Body = body
|
||||
|
||||
' ' Set the format of the mail message body as HTML
|
||||
' mMailMessage.IsBodyHtml = True
|
||||
' ' Set the priority of the mail message to normal
|
||||
' mMailMessage.Priority = MailPriority.Normal
|
||||
|
||||
' ' Instantiate a new instance of SmtpClient
|
||||
' mMailMessage.From = New MailAddress("hutter@shub.ch")
|
||||
' Dim mSmtpClient As New SmtpClient()
|
||||
' ' Send the mail message
|
||||
' mSmtpClient.Send(mMailMessage)
|
||||
' Exit Sub
|
||||
|
||||
' ' Instantiate a new instance of SmtpClient
|
||||
' 'Dim mSmtpClient As New SmtpClient()
|
||||
' 'mMailMessage.From = New MailAddress("info@shub.ch")
|
||||
' 'SendSmtp(mMailMessage)
|
||||
' 'Exit Sub
|
||||
' 'Dim mSmtpClient As New SmtpClient
|
||||
' 'mSmtpClient.Host = "smtp.shub.ch"
|
||||
|
||||
' 'mSmtpClient.Port = 557
|
||||
' 'mSmtpClient.EnableSsl = True
|
||||
' 'mSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
|
||||
' 'mSmtpClient.UseDefaultCredentials = False
|
||||
' 'mSmtpClient.Credentials = New NetworkCredential("hutter@shub.ch", "shu*webland30")
|
||||
' '' Send the mail message
|
||||
' 'mSmtpClient.Send(mMailMessage)
|
||||
' End Sub
|
||||
|
||||
|
||||
' Public Shared Sub Send()
|
||||
|
||||
|
||||
' Const ToAddress As String = "info@shub.ch"
|
||||
|
||||
' '(1) Create the MailMessage instance
|
||||
' Dim mm As New MailMessage("stefan.hutter@stefan-hutter.ch", "info@shub.ch")
|
||||
|
||||
' '(2) Assign the MailMessage's properties
|
||||
' mm.Subject = "Hallo"
|
||||
' mm.Body = "Ich bin ein Test"
|
||||
' mm.IsBodyHtml = False
|
||||
|
||||
' '(3) Create the SmtpClient object
|
||||
' Dim smtp As New SmtpClient
|
||||
|
||||
' '(4) Send the MailMessage (will use the Web.config settings)
|
||||
' smtp.Send(mm)
|
||||
' Exit Sub
|
||||
' End Sub
|
||||
|
||||
' Public Shared Sub SendSmtp(ByVal m As MailMessage)
|
||||
|
||||
' Dim smtp As New SmtpClient
|
||||
' smtp.Host = "smtp.p-hutter.ch"
|
||||
' smtp.Port = 557
|
||||
' smtp.EnableSsl = True
|
||||
' smtp.DeliveryMethod = SmtpDeliveryMethod.Network
|
||||
' smtp.UseDefaultCredentials = False
|
||||
' smtp.Credentials = New NetworkCredential("drhutter@p-hutter.ch", "phu*phut29")
|
||||
' smtp.Send(m)
|
||||
|
||||
' End Sub
|
||||
|
||||
'End Class
|
||||
Reference in New Issue
Block a user