home *** CD-ROM | disk | FTP | other *** search
/ 66.142.0.142 / 66.142.0.142.tar / 66.142.0.142 / askEmailUnconfirmedform.aspx.vb < prev    next >
Text File  |  2014-11-01  |  4KB  |  75 lines

  1. Imports Microsoft.Exchange.WebServices.Data
  2. Imports Microsoft.Exchange.WebServices.Autodiscover
  3. Imports System.Net
  4. Imports System.Net.Security
  5. Imports System.Security.Cryptography.X509Certificates
  6.  
  7. Partial Class askEmailUnconfirmedform
  8.     '    Inherits System.Web.UI.Page
  9.     Inherits AspNetMaker7_tfpssnet
  10.  
  11.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  12.         If Not IsPostBack Then
  13.             If Session("tfpssnet_Status") <> "login" Then
  14.                 Response.Redirect("login.aspx")
  15.             End If
  16.             Dim tmpEmpID As String, tmpEmpName As String, tmpUsername As String, tmpEmpEmail As String, tmpShiftCount
  17.             tmpEmpID = Request.QueryString("empID")
  18.             tmpEmpName = tlcGetEmployeeName(CLng(tmpEmpID))
  19.             lblTo.Text = tmpEmpName
  20.             tmpEmpEmail = tlcGetEmployeeEmail(CLng(tmpEmpID))
  21.             lblEmail.text = tmpEmpEmail
  22.             tmpUsername = tlcGetEmployeeUsernameByName(tmpEmpName)
  23.             tmpShiftCount = tlcGetUnRecCount(tmpUsername)
  24.             lblSubject.Text = "You have " & tmpShiftCount & " unconfirmed shifts."
  25.             lblBody.Text = "You have new unconfirmed shifts in PSS please open PSS and confirm all unconfirmed shifts."
  26.             If tmpShiftCount <= 0 Then btnSubmit.Enabled = False
  27.         End If
  28.     End Sub
  29.  
  30.     Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
  31.         'Dim service As New ExchangeService(requestedServerVersion:=ExchangeVersion.Exchange2010)
  32.         Dim service As New ExchangeService(ExchangeVersion.Exchange2010_SP1)
  33.  
  34.         'Add a valid EWS service end point here or user Autodiscover
  35.         'service.Url = New Uri("https://server14/ews/exchange.asmx")
  36.         service.Url = New Uri("https://outlook.office365.com/EWS/Exchange.asmx")
  37.         'Add a valid user credentials
  38.         'service.Credentials = New WebCredentials("prodservices", "production88", "Business")
  39.         service.Credentials = New WebCredentials("productionservices@tfc.org", "production88")
  40.         service.AutodiscoverUrl("productionservices@tfc.org", AddressOf RedirectionUrlValaditionCallBack)
  41.         'To address the SSL challenge
  42.         ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
  43.         Try
  44.             'Create new message object and set properties required to send a mail
  45.             Dim msg As EmailMessage = New EmailMessage(service)
  46.             msg.Subject = lblSubject.Text
  47.             msg.Body = lblBody.Text
  48.             'msg.ToRecipients.Add("tony.clayton@suddenlink.net")
  49.             'msg.ToRecipients.Add("tonyc@tfchurch.org")
  50.             msg.ToRecipients.Add(lblEmail.Text)
  51.             msg.From = "productionservices@tfc.org"
  52.             msg.SendAndSaveCopy()
  53.             '                                            Message = "Email sent."
  54.         Catch ex As Exception
  55.             Response.Write("<script type='text/javascript'>alert('Error sending email...email not sent.');</script>")
  56.         End Try
  57.  
  58.         Response.Redirect("tblScheduleList.aspx")
  59.     End Sub
  60.  
  61.     Private Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
  62.         'Return True to force the certificate to be accepted.
  63.         Return True
  64.     End Function
  65.  
  66.     Private Shared Function RedirectionUrlValaditionCallBack(ByVal redirectionURL As String) As Boolean
  67.         Dim result As Boolean = False
  68.         Dim redirectionuri As New Uri(redirectionURL)
  69.         If redirectionuri.Scheme = "https" Then
  70.             result = True
  71.         End If
  72.         Return result
  73.     End Function
  74.  
  75. End Class