Wednesday, December 28, 2011
Friday, December 23, 2011
E-Mailer Xml Configuration File
E-Mailer Xml Configuration File
<?xml version="1.0" encoding="utf-8"?>
<Mail>
<SMTP>
<SMTP_Svr_Name>smtp.gmail.com</SMTP_Svr_Name>
<SMTP_Port>465</SMTP_Port>
<SMTP_SSL>1</SMTP_SSL>
</SMTP>
<POP3>
<POP3_Svr_Name>pop.gmail.com</POP3_Svr_Name>
<POP3_Port>995</POP3_Port>
<POP3_SSL>1</POP3_SSL>
</POP3>
<User>
<User_Name>shahab</User_Name>
<E_ID>shahabdhk@gmail.com</E_ID>
<Password>haseena420</Password>
</User>
</Mail>
E-Mailer Sample Application Form
Sample E-Mailer Application Form
Form Codes:
Only Paste Following codes in form Declaration code area
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
M_E_Mails.SendEmail(Tx_To_Address.Text, Tx_Email_Subject.Text, Tx_Body.Text)
End Sub
Form Layout Codes:
Only Paste Following codes in form Declaration code area
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
M_E_Mails.SendEmail(Tx_To_Address.Text, Tx_Email_Subject.Text, Tx_Body.Text)
End Sub
Form Layout Codes:
Paste Following Codes in Form designer
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Email_Sample
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.Tx_To_Address = New System.Windows.Forms.TextBox()
Me.Tx_Email_Subject = New System.Windows.Forms.TextBox()
Me.Tx_Body = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Tx_To_Address
'
Me.Tx_To_Address.Location = New System.Drawing.Point(101, 13)
Me.Tx_To_Address.Name = "Tx_To_Address"
Me.Tx_To_Address.Size = New System.Drawing.Size(379, 20)
Me.Tx_To_Address.TabIndex = 0
'
'Tx_Email_Subject
'
Me.Tx_Email_Subject.Location = New System.Drawing.Point(101, 40)
Me.Tx_Email_Subject.Name = "Tx_Email_Subject"
Me.Tx_Email_Subject.Size = New System.Drawing.Size(379, 20)
Me.Tx_Email_Subject.TabIndex = 1
'
'Tx_Body
'
Me.Tx_Body.Location = New System.Drawing.Point(12, 66)
Me.Tx_Body.Multiline = True
Me.Tx_Body.Name = "Tx_Body"
Me.Tx_Body.Size = New System.Drawing.Size(468, 264)
Me.Tx_Body.TabIndex = 2
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(12, 19)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(20, 13)
Me.Label1.TabIndex = 3
Me.Label1.Text = "To"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(13, 46)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(43, 13)
Me.Label2.TabIndex = 4
Me.Label2.Text = "Subject"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(405, 336)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 5
Me.Button1.Text = "Button1"
Me.Button1.UseVisualStyleBackColor = True
'
'Email_Sample
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(492, 369)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Tx_Body)
Me.Controls.Add(Me.Tx_Email_Subject)
Me.Controls.Add(Me.Tx_To_Address)
Me.Name = "Email_Sample"
Me.Text = "Email_Sample"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Tx_To_Address As System.Windows.Forms.TextBox
Friend WithEvents Tx_Email_Subject As System.Windows.Forms.TextBox
Friend WithEvents Tx_Body As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
End Class
E-Mailer Account Configuration Form
E-Mailer Account Configuration Form
Form Codes:
Just Copy Paste in form Code Area
Private Sub Email_Account_Setting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With M_E_Mails.Load_Mail_Settings()
Tx_Email_ID.Text = .P_Email_Id
Tx_Password.Text = .P_Password
Tx_Pop_Svr_Port.Text = .P_Pop3_Port
If .P_Pop3_SSL.ToString = "1" Then
Chk_Pop_SSL.Checked = True
Else
Chk_Pop_SSL.Checked = False
End If
If .P_Smtp_SSL.ToString = "1" Then
Chk_Smtp_SSL.Checked = True
Else
Chk_Smtp_SSL.Checked = False
End If
Tx_Pop_Svr.Text = .P_Pop3_Svr
Tx_Smtp_Port.Text = .P_Smtp_Port
'Chk_Smtp_SSL.Checked = .P_Smtp_SSL
Tx_Smtp_Svr.Text = .P_Smtp_Svr
Tx_User_Name.Text = .P_User_Name
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SSL_Smtp As String
Dim SSL_Pop3 As String
If Tx_Password.Text = Tx_Conform_Pass.Text Then
If Chk_Pop_SSL.Checked = True Then
SSL_Pop3 = "1"
Else
SSL_Pop3 = "0"
End If
If Chk_Smtp_SSL.Checked = True Then
SSL_Smtp = "1"
Else
SSL_Smtp = "0"
End If
M_E_Mails.Write_Mail_Settings(Tx_Smtp_Svr.Text, Tx_Pop_Svr.Text, Tx_Smtp_Port.Text, _
Tx_Pop_Svr_Port.Text, SSL_Smtp, SSL_Pop3, Tx_Email_ID.Text, _
Tx_Password.Text, Tx_User_Name.Text)
Else
MsgBox("Password Mismach")
End If
Me.Close()
End Sub
Form Layout Codes:
Paste Following Codes in Form designer
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Email_Account_Setting
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.Tx_User_Name = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Tx_Email_ID = New System.Windows.Forms.TextBox()
Me.TabControl1 = New System.Windows.Forms.TabControl()
Me.TabPage1 = New System.Windows.Forms.TabPage()
Me.Tx_Conform_Pass = New System.Windows.Forms.MaskedTextBox()
Me.Tx_Password = New System.Windows.Forms.MaskedTextBox()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.TabPage2 = New System.Windows.Forms.TabPage()
Me.Chk_Smtp_SSL = New System.Windows.Forms.CheckBox()
Me.Chk_Pop_SSL = New System.Windows.Forms.CheckBox()
Me.Tx_Smtp_Port = New System.Windows.Forms.TextBox()
Me.Tx_Pop_Svr_Port = New System.Windows.Forms.TextBox()
Me.Label7 = New System.Windows.Forms.Label()
Me.Label8 = New System.Windows.Forms.Label()
Me.Tx_Smtp_Svr = New System.Windows.Forms.TextBox()
Me.Tx_Pop_Svr = New System.Windows.Forms.TextBox()
Me.Label5 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.TabPage2.SuspendLayout()
Me.SuspendLayout()
'
'Tx_User_Name
'
Me.Tx_User_Name.Location = New System.Drawing.Point(22, 35)
Me.Tx_User_Name.Name = "Tx_User_Name"
Me.Tx_User_Name.Size = New System.Drawing.Size(225, 20)
Me.Tx_User_Name.TabIndex = 0
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(22, 17)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(60, 13)
Me.Label1.TabIndex = 1
Me.Label1.Text = "User Name"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(22, 67)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(46, 13)
Me.Label2.TabIndex = 3
Me.Label2.Text = "Email ID"
'
'Tx_Email_ID
'
Me.Tx_Email_ID.Location = New System.Drawing.Point(22, 85)
Me.Tx_Email_ID.Name = "Tx_Email_ID"
Me.Tx_Email_ID.Size = New System.Drawing.Size(225, 20)
Me.Tx_Email_ID.TabIndex = 2
'
'TabControl1
'
Me.TabControl1.Controls.Add(Me.TabPage1)
Me.TabControl1.Controls.Add(Me.TabPage2)
Me.TabControl1.Location = New System.Drawing.Point(10, 11)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(442, 247)
Me.TabControl1.TabIndex = 5
'
'TabPage1
'
Me.TabPage1.Controls.Add(Me.Tx_Conform_Pass)
Me.TabPage1.Controls.Add(Me.Tx_Password)
Me.TabPage1.Controls.Add(Me.Label4)
Me.TabPage1.Controls.Add(Me.Label3)
Me.TabPage1.Controls.Add(Me.Tx_Email_ID)
Me.TabPage1.Controls.Add(Me.Tx_User_Name)
Me.TabPage1.Controls.Add(Me.Label2)
Me.TabPage1.Controls.Add(Me.Label1)
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Padding = New System.Windows.Forms.Padding(3)
Me.TabPage1.Size = New System.Drawing.Size(434, 221)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "Account Setting"
Me.TabPage1.UseVisualStyleBackColor = True
'
'Tx_Conform_Pass
'
Me.Tx_Conform_Pass.Location = New System.Drawing.Point(22, 180)
Me.Tx_Conform_Pass.Name = "Tx_Conform_Pass"
Me.Tx_Conform_Pass.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
Me.Tx_Conform_Pass.Size = New System.Drawing.Size(225, 20)
Me.Tx_Conform_Pass.TabIndex = 9
'
'Tx_Password
'
Me.Tx_Password.Location = New System.Drawing.Point(22, 134)
Me.Tx_Password.Name = "Tx_Password"
Me.Tx_Password.PasswordChar = Global.Microsoft.VisualBasic.ChrW(42)
Me.Tx_Password.Size = New System.Drawing.Size(225, 20)
Me.Tx_Password.TabIndex = 8
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(22, 163)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(91, 13)
Me.Label4.TabIndex = 7
Me.Label4.Text = "Confirm Password"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(20, 117)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(53, 13)
Me.Label3.TabIndex = 6
Me.Label3.Text = "Password"
'
'TabPage2
'
Me.TabPage2.Controls.Add(Me.Chk_Smtp_SSL)
Me.TabPage2.Controls.Add(Me.Chk_Pop_SSL)
Me.TabPage2.Controls.Add(Me.Tx_Smtp_Port)
Me.TabPage2.Controls.Add(Me.Tx_Pop_Svr_Port)
Me.TabPage2.Controls.Add(Me.Label7)
Me.TabPage2.Controls.Add(Me.Label8)
Me.TabPage2.Controls.Add(Me.Tx_Smtp_Svr)
Me.TabPage2.Controls.Add(Me.Tx_Pop_Svr)
Me.TabPage2.Controls.Add(Me.Label5)
Me.TabPage2.Controls.Add(Me.Label6)
Me.TabPage2.Location = New System.Drawing.Point(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Padding = New System.Windows.Forms.Padding(3)
Me.TabPage2.Size = New System.Drawing.Size(434, 221)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "Mail Setting"
Me.TabPage2.UseVisualStyleBackColor = True
'
'Chk_Smtp_SSL
'
Me.Chk_Smtp_SSL.AutoSize = True
Me.Chk_Smtp_SSL.Location = New System.Drawing.Point(361, 134)
Me.Chk_Smtp_SSL.Name = "Chk_Smtp_SSL"
Me.Chk_Smtp_SSL.Size = New System.Drawing.Size(46, 17)
Me.Chk_Smtp_SSL.TabIndex = 13
Me.Chk_Smtp_SSL.Text = "SSL"
Me.Chk_Smtp_SSL.UseVisualStyleBackColor = True
'
'Chk_Pop_SSL
'
Me.Chk_Pop_SSL.AutoSize = True
Me.Chk_Pop_SSL.Location = New System.Drawing.Point(361, 85)
Me.Chk_Pop_SSL.Name = "Chk_Pop_SSL"
Me.Chk_Pop_SSL.Size = New System.Drawing.Size(46, 17)
Me.Chk_Pop_SSL.TabIndex = 12
Me.Chk_Pop_SSL.Text = "SSL"
Me.Chk_Pop_SSL.UseVisualStyleBackColor = True
'
'Tx_Smtp_Port
'
Me.Tx_Smtp_Port.Location = New System.Drawing.Point(234, 132)
Me.Tx_Smtp_Port.Name = "Tx_Smtp_Port"
Me.Tx_Smtp_Port.Size = New System.Drawing.Size(121, 20)
Me.Tx_Smtp_Port.TabIndex = 10
'
'Tx_Pop_Svr_Port
'
Me.Tx_Pop_Svr_Port.Location = New System.Drawing.Point(234, 82)
Me.Tx_Pop_Svr_Port.Name = "Tx_Pop_Svr_Port"
Me.Tx_Pop_Svr_Port.Size = New System.Drawing.Size(121, 20)
Me.Tx_Pop_Svr_Port.TabIndex = 8
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Location = New System.Drawing.Point(234, 114)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(93, 13)
Me.Label7.TabIndex = 11
Me.Label7.Text = "SMTP Server Port"
'
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.Location = New System.Drawing.Point(234, 64)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(85, 13)
Me.Label8.TabIndex = 9
Me.Label8.Text = "POP Server Port"
'
'Tx_Smtp_Svr
'
Me.Tx_Smtp_Svr.Location = New System.Drawing.Point(22, 132)
Me.Tx_Smtp_Svr.Name = "Tx_Smtp_Svr"
Me.Tx_Smtp_Svr.Size = New System.Drawing.Size(206, 20)
Me.Tx_Smtp_Svr.TabIndex = 6
'
'Tx_Pop_Svr
'
Me.Tx_Pop_Svr.Location = New System.Drawing.Point(22, 82)
Me.Tx_Pop_Svr.Name = "Tx_Pop_Svr"
Me.Tx_Pop_Svr.Size = New System.Drawing.Size(206, 20)
Me.Tx_Pop_Svr.TabIndex = 4
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(22, 114)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(117, 13)
Me.Label5.TabIndex = 7
Me.Label5.Text = "Outgoing SMTP Server"
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(22, 64)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(109, 13)
Me.Label6.TabIndex = 5
Me.Label6.Text = "Incoming POP Server"
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(377, 264)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(75, 23)
Me.Button1.TabIndex = 6
Me.Button1.Text = "Close"
Me.Button1.UseVisualStyleBackColor = True
'
'Email_Account_Setting
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(462, 294)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TabControl1)
Me.Name = "Email_Account_Setting"
Me.Text = "Email_Account_Setting"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
Me.TabPage1.PerformLayout()
Me.TabPage2.ResumeLayout(False)
Me.TabPage2.PerformLayout()
Me.ResumeLayout(False)
End Sub
Friend WithEvents Tx_User_Name As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Tx_Email_ID As System.Windows.Forms.TextBox
Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
Friend WithEvents Tx_Conform_Pass As System.Windows.Forms.MaskedTextBox
Friend WithEvents Tx_Password As System.Windows.Forms.MaskedTextBox
Friend WithEvents Tx_Smtp_Port As System.Windows.Forms.TextBox
Friend WithEvents Tx_Pop_Svr_Port As System.Windows.Forms.TextBox
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents Tx_Smtp_Svr As System.Windows.Forms.TextBox
Friend WithEvents Tx_Pop_Svr As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Chk_Smtp_SSL As System.Windows.Forms.CheckBox
Friend WithEvents Chk_Pop_SSL As System.Windows.Forms.CheckBox
Friend WithEvents Button1 As System.Windows.Forms.Button
End Class
ERP2011 E-Mailer Application
About ERP2011 Email application:
Contents
Modules:
Forms:
XML Files:
Instructions:
Download Codes:
Contents
Modules:
Forms:
XML Files:
Instructions:
Download Codes:
M_Email Module V-1
Imports System.Net.Mail
Imports System.Xml
Module M_E_Mails
Public mail As New MailMessage()
Public Pb_Smtp_Svr As String
Public Pb_Pop3_Svr As String
Public Pb_Smtp_Port As String
Public Pb_Pop3_Port As String
Public Pb_Email_Id As String
Public Pb_Password As String
Public Pb_Smtp_SSL As String
Public Pb_Pop3_SSL As String
Public Pb_User_Name As String
Public Class Get_Email_Config
Property P_Smtp_Svr As String
Property P_Pop3_Svr As String
Property P_Smtp_Port As String
Property P_Pop3_Port As String
Property P_Email_Id As String
Property P_Password As String
Property P_Smtp_SSL As String
Property P_Pop3_SSL As String
Property P_User_Name As String
End Class
Public Function Load_Mail_Settings() As Get_Email_Config
Read_Mail_Settings()
Dim My_Config As New Get_Email_Config
My_Config.P_Smtp_Svr = Pb_Smtp_Svr
My_Config.P_Pop3_Svr = Pb_Pop3_Svr
My_Config.P_Smtp_Port = Pb_Smtp_Port
My_Config.P_Pop3_Port = Pb_Pop3_Port
My_Config.P_Email_Id = Pb_Email_Id
My_Config.P_Password = Pb_Password
My_Config.P_Smtp_SSL = Pb_Smtp_SSL
My_Config.P_Pop3_SSL = Pb_Pop3_SSL
My_Config.P_User_Name = Pb_User_Name
Return My_Config
End Function
Public Sub Read_Mail_Settings()
Dim xDoc As XmlDocument = New XmlDocument()
xDoc.Load("Config_Email.xml")
Dim E_Mail_ID As XmlNodeList = xDoc.GetElementsByTagName("E_ID")
Dim Smtp_Svr As XmlNodeList = xDoc.GetElementsByTagName("SMTP_Svr_Name")
Dim Smtp_Port As XmlNodeList = xDoc.GetElementsByTagName("SMTP_Port")
Dim Smtp_SSL As XmlNodeList = xDoc.GetElementsByTagName("SMTP_SSL")
Dim POP3_Svr As XmlNodeList = xDoc.GetElementsByTagName("POP3_Svr_Name")
Dim POP3_Port As XmlNodeList = xDoc.GetElementsByTagName("POP3_Port")
Dim POP3_SSL As XmlNodeList = xDoc.GetElementsByTagName("POP3_SSL")
Dim User_Name As XmlNodeList = xDoc.GetElementsByTagName("User_Name")
Dim Password As XmlNodeList = xDoc.GetElementsByTagName("Password")
Try
Pb_Smtp_Svr = Smtp_Svr(0).InnerText
Pb_Pop3_Svr = POP3_Svr(0).InnerText
Pb_Smtp_Port = Smtp_Port(0).InnerText
Pb_Pop3_Port = POP3_Port(0).InnerText
Pb_Smtp_SSL = Smtp_SSL(0).InnerText
Pb_Pop3_SSL = POP3_SSL(0).InnerText
Pb_Email_Id = E_Mail_ID(0).InnerText
Pb_Password = Password(0).InnerText
Pb_User_Name = User_Name(0).InnerText
Catch ex As Exception
MsgBox("Read User Login XML.... " & ex.Message)
End Try
End Sub
Public Sub Write_Mail_Settings(ByVal P_Smtp_Svr As String, ByVal P_Pop3_Svr As String, ByVal P_Smtp_Port As String, _
ByVal P_Pop3_Port As String, ByVal P_Smtp_SSL As String, ByVal P_Pop3_SSL As String, _
ByVal P_Email_Id As String, ByVal P_Password As String, ByVal P_User_Name As String)
Dim xDoc As XmlDocument = New XmlDocument()
xDoc.Load("Config_Email.xml")
Dim E_Mail_ID As XmlNodeList = xDoc.GetElementsByTagName("E_ID")
Dim Smtp_Svr As XmlNodeList = xDoc.GetElementsByTagName("SMTP_Svr_Name")
Dim Smtp_Port As XmlNodeList = xDoc.GetElementsByTagName("SMTP_Port")
Dim Smtp_SSL As XmlNodeList = xDoc.GetElementsByTagName("SMTP_SSL")
Dim POP3_Svr As XmlNodeList = xDoc.GetElementsByTagName("POP3_Svr_Name")
Dim POP3_Port As XmlNodeList = xDoc.GetElementsByTagName("POP3_Port")
Dim POP3_SSL As XmlNodeList = xDoc.GetElementsByTagName("POP3_SSL")
Dim User_Name As XmlNodeList = xDoc.GetElementsByTagName("User_Name")
Dim Password As XmlNodeList = xDoc.GetElementsByTagName("Password")
Try
Smtp_Svr(0).InnerText = P_Smtp_Svr
POP3_Svr(0).InnerText = P_Pop3_Svr
Smtp_Port(0).InnerText = P_Smtp_Port
POP3_Port(0).InnerText = P_Pop3_Port
Smtp_SSL(0).InnerText = P_Smtp_SSL
POP3_SSL(0).InnerText = P_Pop3_SSL
E_Mail_ID(0).InnerText = P_Email_Id
Password(0).InnerText = P_Password
User_Name(0).InnerText = P_User_Name
Catch ex As Exception
MsgBox("Read User Login XML.... " & ex.Message)
End Try
xDoc.Save("Config_Email.xml")
End Sub
Public Sub SendEmail(ByVal ToAddress As String, ByVal Mail_Subject As String, ByVal Mail_body As String)
Read_Mail_Settings()
Dim client As New SmtpClient()
Dim sendTo As New MailAddress(ToAddress)
Dim from As MailAddress = New MailAddress(Pb_Email_Id)
Dim message As New MailMessage(from, sendTo)
message.IsBodyHtml = True
message.Subject = Mail_Subject
message.Body = Mail_body
' Use the same account in app.config to authenticate.
Dim basicAuthenticationInfo As New System.Net.NetworkCredential(Pb_Email_Id, Pb_Password)
client.Host = "smtp.gmail.com"
client.UseDefaultCredentials = False
client.Credentials = basicAuthenticationInfo
client.EnableSsl = True
client.Port = 587
Try
client.Send(message)
MsgBox("SUCCESS")
client.Send(message)
MsgBox("SUCCESS")
client.Send(message)
MsgBox("SUCCESS")
Catch ex As Exception
MsgBox("SEND FAIL")
End Try
' 'mail = New MailMessage()
' Dim addr() As String = TextBox1.Text.Split(",")
'Try
'mail.From = New MailAddress("xyz@gmail.com",
' "Web Developers", System.Text.Encoding.UTF8)
'Dim i As Byte
'For i = 0 To addr.Length - 1
'mail.To.Add(addr(i))
'Next
'mail.Subject = TextBox3.Text
'mail.Body = TextBox4.Text
'If ListBox1.Items.Count <> 0 Then
'For i = 0 To ListBox1.Items.Count - 1
' mail.Attachments.Add(New Attachment
' (ListBox1.Items.Item(i)))
'Next
'End If
'mail.DeliveryNotificationOptions =
'DeliveryNotificationOptions.OnFailure()
'mail.ReplyTo = New MailAddress(TextBox1.Text)
'SmtpServer.Send(mail)
'Catch ex As Exception
'MsgBox(ex.ToString())
'End Try
End Sub
End Module
Wednesday, December 21, 2011
M_User_Login
Imports System.Xml
Module M_User_Login
Public Usr_ID As Integer
Public Usr_Name As String
Public Ses_ID As Integer
Public Terminal_Id As Integer
Public Sub Read_User_Loged_Xml()
Dim xDoc As XmlDocument = New XmlDocument()
Dim Ses_ID_Str As String
Dim User_ID_Str As String
Dim Trm_Id_Str As String
xDoc.Load("User_Loged.xml")
Dim UserId As XmlNodeList = xDoc.GetElementsByTagName("User_ID")
Dim UserName As XmlNodeList = xDoc.GetElementsByTagName("User_Name")
Dim TrmID As XmlNodeList = xDoc.GetElementsByTagName("Terminal_ID")
Dim SesID As XmlNodeList = xDoc.GetElementsByTagName("Session_ID")
'Dim TimeLogedIn As XmlNodeList = xDoc.GetElementsByTagName("Time_Loged_In")
'Dim Ses_Guid As XmlNodeList = xDoc.GetElementsByTagName("Session_GUID")
'Dim Usr_Guid As XmlNodeList = xDoc.GetElementsByTagName("User_GUID")
Usr_Name = UserName(0).InnerText
Ses_ID_Str = SesID(0).InnerText
User_ID_Str = UserId(0).InnerText
Trm_Id_Str = TrmID(0).InnerText
Try
If User_ID_Str = String.Empty Then
Usr_ID = 0
ElseIf Ses_ID_Str = String.Empty Then
Ses_ID = 0
ElseIf Trm_Id_Str = String.Empty Then
Terminal_Id = 0
Else
Usr_ID = Convert.ToInt32(User_ID_Str)
Ses_ID = Convert.ToInt32(Ses_ID_Str)
Terminal_Id = Convert.ToInt32(Trm_Id_Str)
End If
Catch ex As Exception
MsgBox("Read User Login XML.... " & ex.Message)
End Try
Get_Terminal()
'MsgBox(Usr_ID & "---" & Ses_ID)
End Sub
Private Sub Write_User_Loged_Xml()
Dim xDoc As XmlDocument = New XmlDocument()
xDoc.Load("User_Loged.xml")
Dim UserId As XmlNodeList = xDoc.GetElementsByTagName("User_ID")
Dim UserName As XmlNodeList = xDoc.GetElementsByTagName("User_Name")
Dim TrmID As XmlNodeList = xDoc.GetElementsByTagName("Terminal_ID")
Dim Ses_ID As XmlNodeList = xDoc.GetElementsByTagName("Session_ID")
'Dim TimeLogedIn As XmlNodeList = xDoc.GetElementsByTagName("Time_Loged_In")
'Dim Ses_Guid As XmlNodeList = xDoc.GetElementsByTagName("Session_GUID")
'Dim Usr_Guid As XmlNodeList = xDoc.GetElementsByTagName("User_GUID")
UserId(0).InnerText = M_User_Login.Usr_ID
UserName(0).InnerText = M_User_Login.Usr_Name
TrmID(0).InnerText = M_User_Login.Terminal_Id
Ses_ID(0).InnerText = M_User_Login.Ses_ID
'Dep_Name(0).InnerText = Tx_Dep_Name.Text
'Trm_Expiry(0).InnerText = Tx_Expiry.Text
'Trm_Cert(0).InnerText = Tx_Trm_Cert.Text
xDoc.Save("User_Loged.xml")
End Sub
Private Sub Log_off_User_Xml()
Dim xDoc As XmlDocument = New XmlDocument()
xDoc.Load("User_Loged.xml")
Dim UserId As XmlNodeList = xDoc.GetElementsByTagName("User_ID")
Dim UserName As XmlNodeList = xDoc.GetElementsByTagName("User_Name")
Dim TrmID As XmlNodeList = xDoc.GetElementsByTagName("Terminal_ID")
Dim Ses_ID As XmlNodeList = xDoc.GetElementsByTagName("Session_ID")
Dim TimeLogedIn As XmlNodeList = xDoc.GetElementsByTagName("Time_Loged_In")
Dim Ses_Guid As XmlNodeList = xDoc.GetElementsByTagName("Session_GUID")
Dim Usr_Guid As XmlNodeList = xDoc.GetElementsByTagName("User_GUID")
UserName(0).InnerText = ""
UserId(0).InnerText = ""
TrmID(0).InnerText = ""
Ses_ID(0).InnerText = ""
TimeLogedIn(0).InnerText = ""
Ses_Guid(0).InnerText = ""
Usr_Guid(0).InnerText = ""
xDoc.Save("User_Loged.xml")
End Sub
Public Sub Usr_Login()
Read_User_Loged_Xml()
If User_Login_Dialog.ShowDialog = DialogResult.OK Then
MsgBox("Starting Login Process Please Waite")
Read_User_Loged_Xml()
If M_User_Login.Usr_Name = String.Empty Or M_User_Login.Ses_ID <= 0 Then
MsgBox("No Previous User Loged")
Close_All_terminal_Sessions()
'De activate all terminal Session if any
'
If User_Login_Dialog.Tx_User.Text <> "" And User_Login_Dialog.Tx_Password.Text <> "" Then
MsgBox("1st Loging in Please waite")
Try
Dim StProc As String
Core.DbCon.Close()
Core.DbCon.Open()
StProc = "Sec.usp_Login"
Dim DbConCmd As New SqlClient.SqlCommand(StProc, Core.DbCon)
DbConCmd.CommandType = CommandType.StoredProcedure
With DbConCmd.Parameters 'Core.DbConCmd.Parameters
.Add("@User_ID", SqlDbType.Int, 10)
DbConCmd.Parameters("@User_ID").Direction = ParameterDirection.Output
.AddWithValue("@User_Name", User_Login_Dialog.Tx_User.Text)
.Add("@User_Name_Out", SqlDbType.VarChar, 50)
DbConCmd.Parameters("@User_Name_Out").Direction = ParameterDirection.Output
.AddWithValue("@Password", User_Login_Dialog.Tx_Password.Text)
End With
DbConCmd.ExecuteNonQuery()
If DbConCmd.Parameters("@User_ID").Value Is DBNull.Value Then
MsgBox("User not Found or wrong Password")
Else
M_User_Login.Usr_ID = DbConCmd.Parameters("@User_ID").Value
End If
If DbConCmd.Parameters("@User_Name_Out").Value Is DBNull.Value Then
MsgBox("User not Found or wrong Password")
User_Login_Dialog.ShowDialog()
Else
M_User_Login.Usr_Name = DbConCmd.Parameters("@User_Name_Out").Value
MsgBox("Creating User Session Please Waite...")
NewSes()
MsgBox("Write local local user Login XML Please Waite...")
Write_User_Loged_Xml()
End If
Core.DbCon.Close()
Catch ex As Exception
MsgBox("User Login Exception... " & ex.ToString)
Core.DbCon.Close()
End Try
Else
MsgBox("Empty User Name or Password not allowed")
User_Login_Dialog.ShowDialog()
End If
Else
If M_User_Login.Usr_Name = String.Empty Or M_User_Login.Ses_ID <= 0 Then
MsgBox("No prevoise session Logged")
logoff()
Close_All_terminal_Sessions()
'De activate all Terminal Sessions"
ElseIf M_User_Login.Ses_ID > 0 Then
If User_Login_Dialog.Tx_User.Text = "" Or User_Login_Dialog.Tx_Password.Text = "" Then
MsgBox("User Name or password is Empty Please Enter User Name and Password")
User_Login_Dialog.ShowDialog()
'End
Else
If M_User_Login.Usr_Name <> User_Login_Dialog.Tx_User.Text Then
MsgBox("User Already Loged in would you like to log off him/Her...")
'Log off current user close all other sessions running on that terminal
If MessageBox.Show("User already Loged in Would you like to logoff Him/Her...", "User Already Loged", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button2) = _
Windows.Forms.DialogResult.Yes Then
'Log off close all active session
'empty user loged xml
'Close all related sessions
logoff()
Log_off_User_Xml()
User_Login_Dialog.ShowDialog()
User_Login_Dialog.Tx_Password.Text = ""
Else
MsgBox("User Canceled the log off action")
End
End If
Else
Step2:
MsgBox("2nd Loging in Please Waite...")
Try
Dim StProc As String
Core.DbCon.Close()
Core.DbCon.Open()
StProc = "Sec.usp_Login"
Dim DbConCmd As New SqlClient.SqlCommand(StProc, Core.DbCon)
DbConCmd.CommandType = CommandType.StoredProcedure
With DbConCmd.Parameters 'Core.DbConCmd.Parameters
.Add("@User_ID", SqlDbType.Int, 10)
DbConCmd.Parameters("@User_ID").Direction = ParameterDirection.Output
.AddWithValue("@User_Name", User_Login_Dialog.Tx_User.Text)
.Add("@User_Name_Out", SqlDbType.VarChar, 50)
DbConCmd.Parameters("@User_Name_Out").Direction = ParameterDirection.Output
.AddWithValue("@Password", User_Login_Dialog.Tx_Password.Text)
End With
DbConCmd.ExecuteNonQuery()
If DbConCmd.Parameters("@User_ID").Value Is DBNull.Value Then
MsgBox("User not Found or wrong Password")
Else
M_User_Login.Usr_ID = DbConCmd.Parameters("@User_ID").Value
End If
If DbConCmd.Parameters("@User_Name_Out").Value Is DBNull.Value Then
MsgBox("User not Found or wrong Password")
User_Login_Dialog.ShowDialog()
GoTo Step2
Else
M_User_Login.Usr_Name = DbConCmd.Parameters("@User_Name_Out").Value
MsgBox("Creating User Session Please Waite...")
NewSes()
MsgBox("Write local local user Login XML Please Waite...")
Write_User_Loged_Xml()
End If
Core.DbCon.Close()
Catch ex As Exception
MsgBox("2nd User Login Exception... " & ex.ToString)
Core.DbCon.Close()
End Try
'Execute Process login
End If
End If
End If
End If
ElseIf User_Login_Dialog.ShowDialog = DialogResult.Cancel Then
End
Else
MsgBox("Closing App")
End If
End Sub
Public Sub Get_Session_Local()
Read_User_Loged_Xml()
If Ses_ID <= 0 Or Usr_Name = String.Empty Then
MsgBox("User or Session ID not Found")
Close_All_terminal_Sessions()
End If
End Sub
Private Sub Get_Sesssion()
End Sub
Public Sub Usr_Logof()
Get_Terminal()
logoff()
Log_off_User_Xml()
Read_User_Loged_Xml()
End Sub
Private Sub All_Trm_Ses_Logoff()
End Sub
Public Sub NewSes()
If Usr_Name = String.Empty Then
Usr_Logof()
All_Trm_Ses_Logoff()
Else
Try
Dim StProc As String
Core.DbCon.Close()
Core.DbCon.Open()
StProc = "Sec.cb_sp_User_Sessions_New"
Dim DbConCmd As New SqlClient.SqlCommand(StProc, Core.DbCon)
DbConCmd.CommandType = CommandType.StoredProcedure
With DbConCmd.Parameters 'Core.DbConCmd.Parameters
.Add("@Session_ID", SqlDbType.Int, 10)
DbConCmd.Parameters("@Session_ID").Direction = ParameterDirection.Output
.AddWithValue("@User_ID", Usr_ID)
.AddWithValue("@Terminal_ID", Terminal_Id)
'.AddWithValue("@Login_Time", )
.AddWithValue("@Active_Session", True)
'.AddWithValue("@Session_GUID", "")
'.AddWithValue("@Logof_Time", "")
End With
DbConCmd.ExecuteNonQuery()
If DbConCmd.Parameters("@Session_ID").Value Is DBNull.Value Then
Else
Ses_ID = DbConCmd.Parameters("@Session_ID").Value
End If
Core.DbCon.Close()
Catch ex As Exception
MsgBox(ex.ToString)
Core.DbCon.Close()
End Try
End If
End Sub
Public Sub CloseSes()
If Ses_ID <= 0 Then
MsgBox("No Active Sesion Found localy...")
Else
Try
Dim StProc As String
Core.DbCon.Close()
Core.DbCon.Open()
StProc = "Sec.cb_sp_User_Sessions_Logoff"
Dim DbConCmd As New SqlClient.SqlCommand(StProc, Core.DbCon)
DbConCmd.CommandType = CommandType.StoredProcedure
With DbConCmd.Parameters 'Core.DbConCmd.Parameters
.AddWithValue("@Session_ID", Ses_ID)
End With
DbConCmd.ExecuteNonQuery()
Core.DbCon.Close()
Catch ex As Exception
MsgBox(ex.ToString)
Core.DbCon.Close()
End Try
End If
End Sub
Private Sub Close_All_terminal_Sessions()
If Terminal_Id <= 0 Then
MsgBox("Getting Terminal ID...Please Waite")
Get_Terminal()
Else
Try
Dim StProc As String
Core.DbCon.Close()
Core.DbCon.Open()
StProc = "Sec.cb_sp_LogOff_AllTerminals"
Dim DbConCmd As New SqlClient.SqlCommand(StProc, Core.DbCon)
DbConCmd.CommandType = CommandType.StoredProcedure
With DbConCmd.Parameters 'Core.DbConCmd.Parameters
.AddWithValue("@Terminal_ID", Terminal_Id)
End With
DbConCmd.ExecuteNonQuery()
Core.DbCon.Close()
Catch ex As Exception
MsgBox(ex.ToString)
Core.DbCon.Close()
End Try
End If
End Sub
Private Sub Get_Terminal()
Dim xDoc As XmlDocument = New XmlDocument()
Dim Trm_ID_Str As String
xDoc.Load("Terminal_Config.xml")
Dim TrmID As XmlNodeList = xDoc.GetElementsByTagName("Terminal_Id")
'Dim Trm_Name As XmlNodeList = xDoc.GetElementsByTagName("Terminal_Name")
'Dim Dep_ID As XmlNodeList = xDoc.GetElementsByTagName("Department_ID")
'Dim Dep_Name As XmlNodeList = xDoc.GetElementsByTagName("Department_Name")
'Dim Trm_Cert As XmlNodeList = xDoc.GetElementsByTagName("Terminal_Cert")
'Dim Trm_Expiry As XmlNodeList = xDoc.GetElementsByTagName("Expiry")
Trm_ID_Str = TrmID(0).InnerText
Try
Terminal_Id = Convert.ToInt32(Trm_ID_Str)
Catch ex As Exception
MsgBox("Get Terminal.... " & ex.Message)
End Try
If Terminal_Id <= 0 Then
MsgBox("Terminal Not Registered Please Contact your System Administrator")
End
End If
End Sub
Private Sub logoff()
MsgBox("Loging off Session Please waite...")
If Ses_ID <= 0 Then
MsgBox("No local Running Session Found...")
Else
Try
Dim StProc As String
Core.DbCon.Close()
Core.DbCon.Open()
StProc = "Sec.cb_sp_User_Sessions_Logoff"
Dim DbConCmd As New SqlClient.SqlCommand(StProc, Core.DbCon)
DbConCmd.CommandType = CommandType.StoredProcedure
With DbConCmd.Parameters 'Core.DbConCmd.Parameters
.AddWithValue("@Session_ID", M_User_Login.Ses_ID)
End With
DbConCmd.ExecuteNonQuery()
Core.DbCon.Close()
Catch ex As Exception
MsgBox("Logging off Error ..." & ex.ToString)
Core.DbCon.Close()
End Try
End If
End Sub
Public Sub Btn_Login(ByVal MyLoginBtn As DevComponents.DotNetBar.ButtonItem)
If MyLoginBtn.Text = "" Or MyLoginBtn.Text = "log Me: " Then
If Check_Login() = True Then
MyLoginBtn.Text = "Logoff: " & M_User_Login.Usr_Name
Else
Usr_Login()
MyLoginBtn.Text = "Logoff: " & M_User_Login.Usr_Name
End If
Else
Usr_Logof()
MyLoginBtn.Text = "log Me: "
End If
End Sub
Public Sub lb_Login(ByRef Login_Lebel As Label)
End Sub
Public Function Check_Login() As Boolean
If Usr_Name <> String.Empty And Ses_ID > 0 Then
Check_Login = True
End If
End Function
End Module
Subscribe to:
Posts (Atom)