142 lines
4.5 KiB
VB.net
142 lines
4.5 KiB
VB.net
Imports System.ComponentModel
|
|
Imports DevExpress.Xpo
|
|
Imports DevExpress.Persistent.Base
|
|
Imports DevExpress.Persistent.BaseImpl
|
|
Imports System.Net.Mail
|
|
Imports System.Net
|
|
|
|
<DefaultClassOptions()>
|
|
<NavigationItem(False)> _
|
|
<CreatableItem(False)> _
|
|
Public Class WebParameters
|
|
Inherits BaseObject
|
|
|
|
Private _SMTPHost As String
|
|
Private _SMTPPort As Long = 25
|
|
Private _SMTPUserName As String
|
|
Private _SMTPPassword As String
|
|
Private _SMTPRequiresAuthentication As Boolean
|
|
|
|
Private _EnableSsl As Boolean
|
|
Private _Email_SupportAdmin As String
|
|
Private _HTMLMailTemplate_QuestionUpdate As HTMLMailTemplate
|
|
Private _HTMLMailTemplate_QuestionStatusUpdate As HTMLMailTemplate
|
|
Private _HTMLMailTemplate_AnswerUpdate As HTMLMailTemplate
|
|
|
|
Public Sub New(ByVal session As Session)
|
|
MyBase.New(session)
|
|
|
|
End Sub
|
|
Public Overrides Sub AfterConstruction()
|
|
MyBase.AfterConstruction()
|
|
EnableSsl = True
|
|
End Sub
|
|
|
|
Property SMTPHost As String
|
|
Get
|
|
Return _SMTPHost
|
|
End Get
|
|
Set(value As String)
|
|
SetPropertyValue("SMTPHost", _SMTPHost, value)
|
|
End Set
|
|
End Property
|
|
Property SMTPPort As Long
|
|
Get
|
|
Return _SMTPPort
|
|
End Get
|
|
Set(value As Long)
|
|
SetPropertyValue("SMTPPort", _SMTPPort, value)
|
|
End Set
|
|
End Property
|
|
Property SMTPUserName As String
|
|
Get
|
|
Return _SMTPUserName
|
|
End Get
|
|
Set(value As String)
|
|
SetPropertyValue("SMTPUserName", _SMTPUserName, value)
|
|
End Set
|
|
End Property
|
|
<PasswordPropertyText()>
|
|
Property SMTPPassword As String
|
|
Get
|
|
Return _SMTPPassword
|
|
End Get
|
|
Set(value As String)
|
|
SetPropertyValue("SMTPPassword", _SMTPPassword, value)
|
|
End Set
|
|
End Property
|
|
Property SMTPRequiresAuthentication As Boolean
|
|
Get
|
|
Return _SMTPRequiresAuthentication
|
|
End Get
|
|
Set(value As Boolean)
|
|
SetPropertyValue("SMTPRequiresAuthentication", _SMTPRequiresAuthentication, value)
|
|
End Set
|
|
End Property
|
|
Property EnableSsl As Boolean
|
|
Get
|
|
Return _EnableSsl
|
|
End Get
|
|
Set(value As Boolean)
|
|
SetPropertyValue("EnableSsl", _EnableSsl, value)
|
|
End Set
|
|
End Property
|
|
Property Email_SupportAdmin As String
|
|
Get
|
|
Return _Email_SupportAdmin
|
|
End Get
|
|
Set(value As String)
|
|
SetPropertyValue("Email_SupportAdmin", _Email_SupportAdmin, value)
|
|
End Set
|
|
End Property
|
|
Property HTMLMailTemplate_QuestionUpdate As HTMLMailTemplate
|
|
Get
|
|
Return _HTMLMailTemplate_QuestionUpdate
|
|
End Get
|
|
Set(value As HTMLMailTemplate)
|
|
SetPropertyValue("HTMLMailTemplate_QuestionUpdate", _HTMLMailTemplate_QuestionUpdate, value)
|
|
End Set
|
|
End Property
|
|
Property HTMLMailTemplate_QuestionStatusUpdate As HTMLMailTemplate
|
|
Get
|
|
Return _HTMLMailTemplate_QuestionStatusUpdate
|
|
End Get
|
|
Set(value As HTMLMailTemplate)
|
|
SetPropertyValue("HTMLMailTemplate_QuestionStatusUpdate", _HTMLMailTemplate_QuestionStatusUpdate, value)
|
|
End Set
|
|
End Property
|
|
Property HTMLMailTemplate_AnswerUpdate As HTMLMailTemplate
|
|
Get
|
|
Return _HTMLMailTemplate_AnswerUpdate
|
|
End Get
|
|
Set(value As HTMLMailTemplate)
|
|
SetPropertyValue("HTMLMailTemplate_AnswerUpdate", _HTMLMailTemplate_AnswerUpdate, value)
|
|
End Set
|
|
End Property
|
|
|
|
Public Function SendMail(_To As String, _Subject As String, _Body As String) As String
|
|
Dim _SmtpClient As SmtpClient = New SmtpClient(SMTPHost)
|
|
Dim _MailMessage As New MailMessage
|
|
Dim _ReturnString As String = ""
|
|
Try
|
|
_SmtpClient.Port = SMTPPort
|
|
If SMTPRequiresAuthentication Then
|
|
_SmtpClient.Credentials = New NetworkCredential(SMTPUserName, SMTPPassword)
|
|
_SmtpClient.EnableSsl = EnableSsl
|
|
Else
|
|
_SmtpClient.UseDefaultCredentials = True
|
|
End If
|
|
_MailMessage.To.Add(_To)
|
|
_MailMessage.From = New MailAddress(Email_SupportAdmin)
|
|
_MailMessage.Subject = ""
|
|
_MailMessage.IsBodyHtml = True
|
|
_MailMessage.Body = ""
|
|
|
|
_SmtpClient.Send(_MailMessage)
|
|
Catch ex As Exception
|
|
_ReturnString = ex.Message
|
|
End Try
|
|
Return _ReturnString
|
|
End Function
|
|
End Class
|