Advertisement
Guest User

SendEmailsModule

a guest
May 9th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 8.62 KB | None | 0 0
  1. Module SendEmailsModule
  2.  
  3.     Public Function SendEmailTimescaleChangedAddNotes()
  4.         'ConnectToDatabase()
  5.         Dim TicketDetails, ReplyDate, Sql As String
  6.         ReplyDate = Format(Now, "dd/MM/yyyy HH:mm:ss")
  7.  
  8.         TicketDetails = ReplyToEmployeeAdditionalNotes.txtAdditionalDetails.Text
  9.  
  10.         Sql = "INSERT INTO tblTicket_Reply_Details (Employee_ID, TechSupport_ID, Reply_Description, Reply_Date) " _
  11.         & "VALUES ('" & TechSupportMenu.grdTickets.CurrentRow.Cells(1).Value.ToString() & "','" & UserIDDatabase & "','" & ReplyToEmployeeAdditionalNotes.txtAdditionalDetails.Text & "' , '" & ReplyDate & "')"
  12.         ReplyToEmployeeAdditionalNotes.Close()
  13.         db.connect()
  14.         ds = db.sqltblSubmitted_Ticket_Details(Sql)
  15.         db.Close()
  16.  
  17.  
  18.         Dim EmployeeNumbers As String 'This code makes a variable to skip an amount of characters in a label, so just the numbers in my label are used in my sql
  19.         'ticketnumbers2 is made because otherwise multiple variable declarations will be in the same enclosing block
  20.         EmployeeNumbers = Mid(ReplyToEmployee.lblEmployeeID.Text, 14, 18)
  21.         Dim sql2 As String
  22.         sql2 = "SELECT Employee_Email FROM tblEmployee_Details WHERE Employee_ID = '" & EmployeeNumbers & "'"
  23.         db.connect()
  24.         ds = db.sqlEmployeeEmailSql2(sql2)
  25.         db.Close()
  26.  
  27.         Dim EmployeeEmail As String
  28.         EmployeeEmail = (ds.Tables("EmployeeEmail").Rows(0).Item(0))    'Navigates to value in ds array and stores it as a string variable
  29.  
  30.  
  31.         Dim Outlook As Microsoft.Office.Interop.Outlook._Application
  32.         Outlook = New Microsoft.Office.Interop.Outlook.Application
  33.  
  34.         Dim Msg As Microsoft.Office.Interop.Outlook.MailItem
  35.         Msg = Outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
  36.  
  37.         Msg.Subject = "Details Concerning Your Ticket"
  38.         Msg.Body = TicketDetails
  39.         'Sends custom message where controls = text user puts in
  40.         Msg.To = EmployeeEmail
  41.         ' Msg.CC = "fredsls1234@gmail.com"
  42.  
  43.         Msg.Send()
  44.         MessageBox.Show("An Email has also been sent successfully to the Employee!", ReplyToEmployee.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  45.         'Verifies if email has been sent successful or not
  46.         con.Close()
  47.         Return ReplyToEmployee.Text
  48.     End Function
  49.  
  50.     Public Function SendEmailTicketSolved()
  51.         Dim TicketDetails, ReplyDate As String
  52.         ReplyDate = Format(Now, "dd/MM/yyyy HH:mm")
  53.  
  54.         TicketDetails = ReplyToEmployeeAdditionalNotes.txtAdditionalDetails.Text
  55.  
  56.         ReplyToEmployeeAdditionalNotes.Close()
  57.  
  58.         Dim EmployeeNumbers As String 'This code makes a variable to skip an amount of characters in a label, so just the numbers in my label are used in my sql
  59.         'ticketnumbers2 is made because otherwise multiple variable declarations will be in the same enclosing block
  60.         EmployeeNumbers = Mid(ReplyToEmployee.lblEmployeeID.Text, 14, 18)
  61.         Dim sql2 As String
  62.         sql2 = "SELECT Employee_Email FROM tblEmployee_Details WHERE Employee_ID = '" & EmployeeNumbers & "'"
  63.         db.connect()
  64.         ds = db.sqlEmployeeEmailSql2(sql2)
  65.         db.Close()
  66.  
  67.         Dim EmployeeEmail As String
  68.         EmployeeEmail = (ds.Tables("EmployeeEmail").Rows(0).Item(0))    'Navigates to value in ds array and stores it as a string variable
  69.         'Connects to outlook------------------------------------------
  70.         Dim Outlook As Microsoft.Office.Interop.Outlook._Application
  71.         Outlook = New Microsoft.Office.Interop.Outlook.Application
  72.         Dim Msg As Microsoft.Office.Interop.Outlook.MailItem
  73.         Msg = Outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
  74.  
  75.         Msg.Subject = "Details Concerning Your Ticket"
  76.         Msg.Body = "Your ticket has been solved. Thank you for using GE Tech Support."
  77.         'Sends custom message where controls = text user puts in
  78.         Msg.To = EmployeeEmail
  79.         ' Msg.CC = "fredsls1234@gmail.com"
  80.  
  81.         Msg.Send()
  82.         MessageBox.Show("An Email has also been sent successfully to the Employee!", ReplyToEmployee.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  83.         'Verifies if email has been sent successful or not
  84.         con.Close()
  85.         Return ReplyToEmployee.Text
  86.     End Function
  87.  
  88.     Public Function SendEmailTimescaleChangedNoNotes()
  89.         Dim TicketDetails, ReplyDate, Sql As String
  90.         ReplyDate = Format(Now, "dd/MM/yyyy HH:mm")
  91.  
  92.         TicketDetails = ReplyToEmployeeAdditionalNotes.txtAdditionalDetails.Text
  93.  
  94.         Sql = "INSERT INTO tblTicket_Reply_Details (Employee_ID, TechSupport_ID, Reply_Description, Reply_Date) VALUES " _
  95.         & "('" & TechSupportMenu.grdTickets.CurrentRow.Cells(1).Value.ToString() & "','" & UserIDDatabase & "', ""Your Ticket is taking longer than expected to solve and your Timescale has been changed. Thank you for your patience!"" , '" & ReplyDate & "')"
  96.         ReplyToEmployeeAdditionalNotes.Close()
  97.         db.connect()
  98.         ds = db.sqltblSubmitted_Ticket_Details(Sql)
  99.         db.Close()
  100.  
  101.  
  102.         Dim EmployeeNumbers As String 'This code makes a variable to skip an amount of characters in a label, so just the numbers in my label are used in my sql
  103.         'ticketnumbers2 is made because otherwise multiple variable declarations will be in the same enclosing block
  104.         EmployeeNumbers = Mid(ReplyToEmployee.lblEmployeeID.Text, 14, 18)
  105.         Dim sql2 As String
  106.         sql2 = "SELECT Employee_Email FROM tblEmployee_Details WHERE Employee_ID = '" & EmployeeNumbers & "'"
  107.         db.connect()
  108.         ds = db.sqlEmployeeEmailSql2(sql2)
  109.         db.Close()
  110.  
  111.         Dim EmployeeEmail As String
  112.         EmployeeEmail = (ds.Tables("EmployeeEmail").Rows(0).Item(0))    'Navigates to value in ds array and stores it as a string variable
  113.  
  114.  
  115.         Dim Outlook As Microsoft.Office.Interop.Outlook._Application
  116.         Outlook = New Microsoft.Office.Interop.Outlook.Application
  117.  
  118.         Dim Msg As Microsoft.Office.Interop.Outlook.MailItem
  119.         Msg = Outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
  120.  
  121.         Msg.Subject = "Details Concerning Your Ticket"
  122.         Msg.Body = "Your ticket is taking slightly longer than usual to solve and we have extended the deadline. Please see your sent tickets to see the new deadline."
  123.         'Sends custom message where controls = text user puts in
  124.         Msg.To = EmployeeEmail
  125.         ' Msg.CC = "fredsls1234@gmail.com"
  126.  
  127.         Msg.Send()
  128.         MessageBox.Show("An Email has also been sent successfully to the Employee!", ReplyToEmployee.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  129.         'Verifies if email has been sent successful or not
  130.         Return ReplyToEmployee.Text
  131.     End Function
  132.  
  133.     Public Function SendEmailToCorrectEmployee()
  134.         Dim EmployeeNumbers, EmployeeEmail, sql2, TicketDetails As String 'This code makes a variable to skip an amount of characters in a label, so just the numbers in my label are used in my sql
  135.         'ticketnumbers2 is made because otherwise multiple variable declarations will be in the same enclosing block
  136.  
  137.         EmployeeNumbers = Mid(ReplyToEmployee.lblEmployeeID.Text, 14, 18)
  138.         TicketDetails = ReplyToEmployeeAdditionalNotes.txtAdditionalDetails.Text
  139.         con.Open()
  140.         sql2 = "SELECT Employee_Email FROM tblEmployee_Details WHERE Employee_ID = '" & EmployeeNumbers & "'"
  141.         db.connect()
  142.         ds = db.sqlEmployeeEmailSql2(sql2)
  143.         db.Close()
  144.  
  145.         EmployeeEmail = (ds.Tables("EmployeeEmail").Rows(0).Item(0))    'Navigates to value in ds array and stores it as a string variable
  146.  
  147.  
  148.         Dim Outlook As Microsoft.Office.Interop.Outlook._Application
  149.         Outlook = New Microsoft.Office.Interop.Outlook.Application
  150.  
  151.         Dim Msg As Microsoft.Office.Interop.Outlook.MailItem
  152.         Msg = Outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
  153.  
  154.         Msg.Subject = "Details Concerning Your Ticket"
  155.         Msg.Body = TicketDetails
  156.         'Sends custom message where controls = text user puts in
  157.         Msg.To = EmployeeEmail
  158.  
  159.         Msg.Send()
  160.         MessageBox.Show("An Email has also been sent successfully to the Employee!", ReplyToEmployee.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  161.         'Verifies if email has been sent successful or not
  162.         Return ReplyToEmployee.Text
  163.     End Function
  164.  
  165.     Public Function SendEmailToAllTechSupport()
  166.         Dim sql As String = "SELECT TechSupport_Email FROM tblTechSupport_Details"
  167.         db.connect()
  168.         ds = db.sqlTechSupportEmail(sql)
  169.         db.Close()
  170.         Return ds
  171.     End Function
  172. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement