Guest User

Untitled

a guest
Jun 18th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2.     .SYNOPSIS
  3.         Sends Email Notifications with consistant formatting to selected distribution lists
  4.     .DESCRIPTION
  5.         Ability to change template based on the type of notification being sent with a multitude of customisations
  6.         and options for embedding images and attach documents (docx & pdfs)
  7.     .NOTES
  8.         Version 1.4
  9. #>
  10. #region PARAMETERS
  11.  
  12.     Param(
  13.     [int]$DisplayMode = 4,
  14.     [int]$SelectionCount = 1,
  15.     [datetime]$TodayDate = $(Get-Date),
  16.     [datetime]$DateSelected = $TodayDate,
  17.     $FirstDayofWeek = -1,
  18.     [datetime[]]$Bold = @(),
  19.     [datetime[]]$YBold = @(),
  20.     [datetime[]]$MBold = @(),
  21.     [int]$ScrollBy = $DisplayMode,
  22.     [switch]$WeekNumbers,
  23.     [string]$Title = "Date Picker",
  24.     [switch]$NoTodayCircle,
  25.     [datetime]$MinDate = [datetime]"2017-01-01",
  26.     [datetime]$MaxDate = [datetime]"2018-12-31"
  27.     )
  28.     $script:OutageArray =@()
  29.     $script:AddressList =@()
  30.     $script:OutageArrayAtt =@()
  31.     $script:SectionArray = New-Object object[] 5
  32.     $script:ScriptPath = $PSScriptRoot
  33.  
  34.     $script:BannerInformation = $PSScriptRoot+"\"+"information.png"
  35.     $script:BannerWarning = $PSScriptRoot+"\"+"warning.png"
  36.     $script:BannerOutage = $PSScriptRoot+"\"+"outage.png"
  37.     #endregion PARAMETERS
  38. #region DECLARE FUNCTIONS
  39.     #region EMAIL CREATION
  40.         Function Send-Email()
  41.         {
  42.         Param($PeerReview)
  43.         $Email = New-Object system.net.mail.mailmessage
  44.         $Today = Get-Date -Hour 0 -Minute 0 -Second 1 -Millisecond 0
  45.        
  46.         $script:HTMLName = "EmailNotification.html"
  47.         $script:frmSubject = $txtSubject.Text
  48.         $script:frmDate = $txtDate.Text
  49.         $script:frmAffectedServices = $txtAffectedServices.Text.Replace("`n", "<br>")
  50.         $script:frmOutage = $txtOutage.Text.Replace("`n", "<br>")
  51.         $script:frmYou = $txtYou.Text.Replace("`n", "<br>")
  52.         if ($PeerReview -eq "True") {$script:frmTo = "<username>@<domain>"
  53.                                      $script:Subject = "[PEER REVIEW] - $frmSubject"
  54.                                      $btnSend.Visible = $True
  55.                                      $btnPeerReview.Visible = $False
  56.                                      $NotificationType = 'High'}
  57.             else {$script:frmTo = $txtEmailTo.Text
  58.                   $script:Subject = "[APAC IT] - $frmSubject"}
  59.         $script:frmBCC = $txtBCC.Text
  60.         $script:frmAffectedServicesTitle = $lblAffectedServices.Text
  61.         $script:frmYouTitle = $lblYou.Text
  62.             #region ATTACHMENT TO SECTION
  63.                 if ($ddSection1.Text -eq "1") {
  64.                     $script:SectionArray[0] = "SERVICESIMG"}
  65.                     elseif ($ddSection1.Text -eq "2") {
  66.                     $script:SectionArray[0] = "OUTAGEIMG"}
  67.                     elseif ($ddSection1.Text -eq "3") {
  68.                     $script:SectionArray[0] = "YOUIMG"}
  69.                
  70.                 if ($ddSection2.Text -eq "1") {
  71.                     $script:SectionArray[1] = "SERVICESIMG"}
  72.                     elseif ($ddSection2.Text -eq "2") {
  73.                     $script:SectionArray[1] = "OUTAGEIMG"}
  74.                     elseif ($ddSection2.Text -eq "3") {
  75.                     $script:SectionArray[1] = "YOUIMG"}
  76.                
  77.                 if ($ddSection3.Text -eq "1") {
  78.                     $script:SectionArray[2] = "SERVICESIMG"}
  79.                     elseif ($ddSection3.Text -eq "2") {
  80.                     $script:SectionArray[2] = "OUTAGEIMG"}
  81.                     elseif ($ddSection3.Text -eq "3") {
  82.                     $script:SectionArray[2] = "YOUIMG"}
  83.  
  84.                 if ($ddSection4.Text -eq "1") {
  85.                     $script:SectionArray[3] = "SERVICESIMG"}
  86.                     elseif ($ddSection4.Text -eq "2") {
  87.                     $script:SectionArray[3] = "OUTAGEIMG"}
  88.                     elseif ($ddSection4.Text -eq "3") {
  89.                     $script:SectionArray[3] = "YOUIMG"}
  90.  
  91.                 if ($ddSection5.Text -eq "1") {
  92.                     $script:SectionArray[4] = "SERVICESIMG"}
  93.                     elseif ($ddSection5.Text -eq "2") {
  94.                     $script:SectionArray[4] = "OUTAGEIMG"}
  95.                     elseif ($ddSection5.Text -eq "3") {
  96.                     $script:SectionArray[4] = "YOUIMG"}
  97.                     #endregion ATTACHMENTMENT TO SECTION
  98.         $script:frmOutageStartDateTitle = $lblOutageStartDate.Text
  99.         $script:frmOutageStartTimeTitle = $lblOutageStartTime.Text
  100.         $script:frmOutageEndDateTitle = $lblOutageEndDate.Text
  101.         $script:frmOutageEndTimeTitle = $lblOutageEndTime.Text
  102.         $script:frmOutageStartDate = $txtOutageStartDate.Text
  103.         $script:frmOutageEndDate = $txtOutageEndDate.Text
  104.         $script:frmOutageStartTimeHH = $ddOutageStartTimeHH.Text
  105.         $script:frmOutageStartTimeMM = $ddOutageStartTimeMM.Text
  106.         $script:frmOutageStartTimeAMPM = $script:rbOutageStartTimeAMPM
  107.         $script:frmOutageEndTimeHH = $ddOutageEndTimeHH.Text
  108.         $script:frmOutageEndTimeMM = $ddOutageEndTimeMM.Text
  109.         $script:frmOutageEndTimeAMPM = $script:rbOutageEndTimeAMPM
  110.         $script:frmBanner = $pbBanner.ImageLocation
  111.             If ($ddType.Text -eq "Outage")      {$script:frmOutageTitle = $script:outageTitle}
  112.             Else                                {$script:frmOutageTitle = $lblOutage1.Text}
  113.  
  114.         $Counter = 1
  115.         $IMGCounter = 1
  116.         $SectionCounter = 0
  117.  
  118.     #region BODY REPLACE
  119.         $script:Body = Get-Content -Path $($script:ScriptPath+"\"+$script:HTMLName) | Out-String
  120.         If ($PeerReview -eq "True") {$script:Body = $Body.Replace("[DATE]","<b>Emailing: "+ $txtEmailTo.Text + "</b>")}
  121.             Else {$script:Body = $Body.Replace("[DATE]",$frmDate)}
  122.         $script:Body = $Body.Replace("[SERVICES]",$frmAffectedServicesTitle)
  123.         $script:Body = $Body.Replace("<SERVICES>",$frmAffectedServices)
  124.         $script:Body = $Body.Replace("[YOU]",$frmYouTitle)
  125.         $script:Body = $Body.Replace("<YOU>",$frmYou)
  126.         $script:Body = $Body.Replace("<OUTAGE>",$frmOutage)
  127.  
  128.         If ($ddType.Text -eq "Outage"){
  129.             $script:Body = $Body.Replace("<OutageForm>","<table  width=""100%"" border=""0""><tr class=""MsoNormal""><td><b>`
  130.             $frmOutageStartDateTitle</b></td><td>$frmOutageStartDate</td></tr><tr class=""MsoNormal""><td><b>`
  131.             $frmOutageStartTimeTitle</b></td><td>$frmOutageStartTimeHH`:$frmOutageStartTimeMM $frmOutageStartTimeAMPM</td><tr class=""MsoNormal""><td></td><td></td></tr><tr class=""MsoNormal""><td><b>`
  132.             $frmOutageEndDateTitle</b></td><td>$frmOutageEndDate</td><tr class=""MsoNormal""><td><b>`
  133.             $frmOutageEndTimeTitle</b></td><td>$frmOutageEndTimeHH`:$frmOutageEndTimeMM $frmOutageEndTimeAMPM</td></tr></table>")
  134.                 if ($rbOutageTypeUN.Checked -eq $True) {$script:Body = $Body.Replace("[OutageTitle]",$rbOutageTypeUN.Tag+" Outage Window")}
  135.                 elseif ($rbOutageTypeSC.Checked -eq $True) {$script:Body = $Body.Replace("[OutageTitle]",$rbOutageTypeSC.Tag+" Outage Window")}
  136.             }
  137.         Else {$script:Body = $Body.Replace("[OutageTitle]",$frmOutageTitle)}
  138.         #endregion BODY REPLACE
  139.     #region EMBED IMAGE LOOP
  140.         foreach ($Image in $script:OutageArray){
  141.             $TempImgAttach = new-object Net.Mail.Attachment($Image)
  142.             $TempImgAttach.ContentDisposition.Inline = $True
  143.             $TempImgAttach.ContentDisposition.DispositionType = "Inline"
  144.                 if      ($TempImgAttach.Name -like "*.png")     {$TempImgAttach.ContentType.MediaType = "image/png"}
  145.                 elseif  ($TempImgAttach.Name -like "*.jpg")     {$TempImgAttach.ContentType.MediaType = "image/jpg"}
  146.                 elseif  ($TempImgAttach.Name -like "*.jpeg")    {$TempImgAttach.ContentType.MediaType = "image/jpeg"}
  147.             $TempImgAttach.ContentId = "Attachment" + $Counter
  148.             $TempImgAttach.ContentType.Name = $TempImgAttach.Name
  149.             $Email.Attachments.Add($TempImgAttach)
  150.  
  151.             $frmSectionVar = $script:SectionArray[$SectionCounter]
  152.             $frmSectionVarFull = $frmSectionVar+$IMGCounter
  153.  
  154.             $IMGSrc = "<BR><img src=`'cid:$($TempImgAttach.ContentId)`' /><BR><BR>"
  155.             $Body = $Body.Replace("<"+$frmSectionVarFull+">",$IMGSrc)
  156.         #region INCREASE LOOP COUNT
  157.             $IMGCounter++
  158.             $Counter++
  159.             $SectionCounter++
  160.         }
  161.         #endregion INCREASE LOOP COUNT
  162.         #endregion EMBED IMAGE LOOP
  163.     #region BANNER EMBED
  164.         $BannerCounter = 10
  165.         $BannerAtt = new-object Net.Mail.Attachment($script:frmBanner)
  166.         $BannerAtt.ContentDisposition.Inline = $True
  167.         $BannerAtt.ContentDisposition.DispositionType = "Inline"
  168.         $BannerAtt.ContentType.MediaType = "image/png"
  169.         $BannerAtt.ContentId = "Attachment" + $BannerCounter
  170.         $BannerAtt.ContentType.Name = $BannerAtt.Name
  171.         $Email.Attachments.Add($BannerAtt)
  172.         $BannerIMGSrc = "<img src=`'cid:$($BannerAtt.ContentId)`' />"
  173.         $Body = $Body.Replace("<banner>",$BannerIMGSrc)
  174.         #endregion BANNER EMBED
  175.     #region START DOCUMENT ATTACHMENT
  176.         foreach ($Doc in $script:OutageArrayAtt){
  177.             $TempDocAttach = new-object Net.Mail.Attachment($Doc)
  178.             $Email.Attachments.Add($TempDocAttach)
  179.         }
  180.         #endregion START DOCUMENT ATTACHMENT
  181.     #region SEND EMAIL
  182.         $Email.From = "IT <IT@<domain>>"
  183.         $Email.Subject = $script:Subject
  184.         $Email.Body = $Body
  185.         $Email.IsBodyHTML = $True
  186.         $Email.ReplyTo = "IT.Support@<domain>"
  187.         $Email.Priority = $NotificationType
  188.         # $Email.To.Add("<username>@<domain>")
  189.             if ($script:frmBCC) {$Email.BCC.Add("$script:frmBCC")}
  190.                 else {# do nothing
  191.                         }
  192.             if ($script:frmTo) {$Email.To.Add("$script:frmTo")}
  193.                     else {# do nothing
  194.                             }
  195.         $SMTPClient = New-Object Net.Mail.SmtpClient("<SMTP ADDRESS>", 25 )
  196.             if ($script:frmBCC -or $script:frmTo) {$SMTPClient.Send($Email)} #wont send email without an address in TO or BCC
  197.                 else {# do nothing
  198.             }
  199.      }
  200.         #endregion SEND EMAIL
  201.         #endregion EMAIL CREATION
  202.     #region DATE PICKER
  203.         Function Get-DateOrdinalSuffix([datetime]$Date) {
  204.             switch -regex ($Date.Day.ToString()) {
  205.             '1(1|2|3)$' { 'th'; break }
  206.             '.?1$'      { 'st'; break }
  207.             '.?2$'      { 'nd'; break }
  208.             '.?3$'      { 'rd'; break }
  209.             default     { 'th'; break }
  210.             }
  211.             }
  212.  
  213.         Function Show-BalloonTip  
  214.         {
  215.         #[CmdletBinding(SupportsShouldProcess = $True)]
  216.         Param
  217.             (
  218.         [Parameter(Mandatory=$True)]
  219.         $Text,
  220.         [Parameter(Mandatory=$True)]
  221.         $Title,
  222.         [ValidateSet('None', 'Info', 'Warning', 'Error')]
  223.         $Icon = 'Info',
  224.         $Timeout = 10000
  225.             )
  226.  
  227.         if ($script:balloon -eq $null)
  228.             {
  229.             $script:balloon = New-Object System.Windows.Forms.NotifyIcon
  230.             }
  231.             $path                   = Get-Process -id $pid | Select-Object -ExpandProperty Path
  232.             $balloon.Icon           = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
  233.             $balloon.BalloonTipIcon = $Icon
  234.             $balloon.BalloonTipText = $Text
  235.             $balloon.BalloonTipTitle = $Title
  236.             $balloon.Visible        = $True
  237.  
  238.             $balloon.ShowBalloonTip($Timeout)
  239.         }
  240.  
  241.         Function Get-SuffixAndClipboard {
  242.         if(!$Escaped){
  243.             for(
  244.                 $day = $cal.SelectionRange.Start;
  245.                 $day -le $cal.SelectionRange.End;
  246.                 $day = $day.AddDays(1)
  247.                 )
  248.                 {
  249.                     $suffix = Get-DateOrdinalSuffix $day
  250.                     $DateFormatted = "{0} the {2}{3} of {1:MMMM} {4}" -f $day.DayOfWeek, $day, $day.Day, $suffix, $day.Year
  251.                     $DateFormatted | clip.exe
  252.                     Show-BalloonTip -Text "$DateFormatted has been added to your clipboard" -Title "Clipboard Updated" -icon Info
  253.                 }
  254.             }
  255.         }
  256.         #endregion DATE PICKER
  257.     #region GET DATE ORDINAL
  258.         Function Get-DateOrdinalSuffix1
  259.             {
  260.             $txtDateToday = (Get-Date)
  261.             $suffix1 = Get-DateOrdinalSuffix $txtDateToday
  262.             $DateFormattedTxtBox ="{0} the {1}{2} of {3:MMMM} {4}" -f $txtDateToday.DayOfWeek, $txtDateToday.Day, $suffix1, $txtDateToday, $txtDateToday.Year
  263.             $DateFormattedTxtBox
  264.             }
  265.             #endregion GET DATE ORDINAL
  266.     #region DOCUMENT PICKER
  267.         Function Get-FileNameDoc ($initialDirectory)
  268.         {
  269.         [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
  270.         $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
  271.         $OpenFileDialog.Multiselect = $True
  272.         $OpenFileDialog.Title = "Choose a Document"
  273.         $OpenFileDialog.InitialDirectory = $initialDirectory
  274.         $OpenFileDialog.Filter = 'Document (*.docx, *.pdf)|*.docx;*.pdf'
  275.         $OpenFileDialog.ShowDialog() | Out-Null
  276.         $OpenFileDialog.FileNames | ForEach-Object {[Void]$txtOutageAtt.Items.Add($_)}
  277.         ForEach ($Item in $txtOutageAtt.Items)
  278.         {$script:OutageArrayAtt += $Item}
  279.         }
  280.         #endregion DOCUMENT PICKER
  281.     #region IMAGE PICKER
  282.         Function Get-FileName ($initialDirectory)
  283.         {
  284.         [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
  285.         $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
  286.         $OpenFileDialog.Multiselect = $True
  287.         $OpenFileDialog.Title = "Choose an image"
  288.         $OpenFileDialog.InitialDirectory = $initialDirectory
  289.         $OpenFileDialog.Filter = 'Images (*.jpg, *.png)|*.jpg;*.png'
  290.         $OpenFileDialog.ShowDialog() | Out-Null
  291.         $OpenFileDialog.FileNames | ForEach-Object {[Void]$txtOutageIMG1.Items.Add($_)}
  292.         ForEach ($Item in $txtOutageIMG1.Items)
  293.         {$script:OutageArray += $Item}
  294.         }
  295.         #endregion IMAGE PICKER
  296.     #region ADDRESS PICKER FORM & FUNCTION
  297.         Function Get-Addresses () {
  298.             $Script:AddressListArray =@()
  299.  
  300.             $AddressForm = New-Object system.Windows.Forms.Form
  301.             $AddressForm.Text = "Address Picker"
  302.             $AddressForm.TopMost = $True
  303.             $AddressForm.Width = 430
  304.             $AddressForm.Height = 740
  305.             $AddressForm.KeyPreview = $True
  306.             $AddressForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {
  307.                         # If {Enter} Do {Nothing}
  308.                     }
  309.                 })
  310.             $AddressForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {
  311.                 $AddressForm.Close()
  312.             }
  313.         })
  314.  
  315.             $lbAddressList = New-Object System.Windows.Forms.ListBox
  316.             $lbAddressList.Name = "Address List"
  317.             $Script:AddressList = $Script:AddressListArray =@()
  318.             $Script:AddressList = $lbAddressList.Items
  319.             ForEach ($Item in $Script:AddressList)
  320.             {$Script:AddressList += $Item}
  321.         $handler_button1_Click={
  322.             $lbAddressList.Items.Clear();
  323.                 if ($EmailAddress01.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  324.                 if ($EmailAddress02.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  325.                 if ($EmailAddress03.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  326.                 if ($EmailAddress04.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  327.                 if ($EmailAddress05.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  328.                 if ($EmailAddress06.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  329.                 if ($EmailAddress07.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  330.                 if ($EmailAddress08.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  331.                 if ($EmailAddress09.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  332.                 if ($EmailAddress10.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  333.                 if ($EmailAddress11.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  334.                 if ($EmailAddress12.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  335.                 if ($EmailAddress13.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  336.                 if ($EmailAddress14.Checked)    {$lbAddressList.Items.Add("@<<domain>>")}
  337.                 if ( !$EmailAddress01.Checked -and !$EmailAddress02.Checked -and !$EmailAddress03.Checked -and !$EmailAddress04.Checked -and !$EmailAddress05.Checked -and !$EmailAddress06.Checked -and !$EmailAddress07.Checked -and !$EmailAddress08.Checked -and !$EmailAddress09.Checked -and !$EmailAddress10.Checked -and !$EmailAddress11.Checked -and !$EmailAddress12.Checked -and !$EmailAddress13.Checked -and !$EmailAddress14.Checked ) {   $lbAddressList.Items.Add("No distribution list selected....")}
  338.             }
  339.     #region EMAIL ADDRESS LIST
  340.             $EmailAddress01 = new-object System.Windows.Forms.checkbox
  341.             $EmailAddress01.Location = new-object System.Drawing.Size(30,20)
  342.             $EmailAddress01.Size = new-object System.Drawing.Size(520,50)
  343.             $EmailAddress01.Text = "<@<domain>>"
  344.             $EmailAddress01.Checked = $False
  345.             $EmailAddress01.add_click($handler_button1_Click)
  346.             $AddressForm.Controls.Add($EmailAddress01)
  347.  
  348.             $EmailAddress02 = new-object System.Windows.Forms.checkbox
  349.             $EmailAddress02.Location = new-object System.Drawing.Size(30,60)
  350.             $EmailAddress02.Size = new-object System.Drawing.Size(520,50)
  351.             $EmailAddress02.Text = "<@<domain>"
  352.             $EmailAddress02.Checked = $False
  353.             $EmailAddress02.add_click($handler_button1_Click)
  354.             $AddressForm.Controls.Add($EmailAddress02)
  355.  
  356.             $EmailAddress03 = new-object System.Windows.Forms.checkbox
  357.             $EmailAddress03.Location = new-object System.Drawing.Size(30,100)
  358.             $EmailAddress03.Size = new-object System.Drawing.Size(520,50)
  359.             $EmailAddress03.Text = "@<domain>>"
  360.             $EmailAddress03.Checked = $False
  361.             $EmailAddress03.add_click($handler_button1_Click)
  362.             $AddressForm.Controls.Add($EmailAddress03)
  363.  
  364.             $EmailAddress04 = new-object System.Windows.Forms.checkbox
  365.             $EmailAddress04.Location = new-object System.Drawing.Size(30,140)
  366.             $EmailAddress04.Size = new-object System.Drawing.Size(520,50)
  367.             $EmailAddress04.Text = "<@<domain>>"
  368.             $EmailAddress04.Checked = $False
  369.             $EmailAddress04.add_click($handler_button1_Click)
  370.             $AddressForm.Controls.Add($EmailAddress04)
  371.  
  372.             $EmailAddress05 = new-object System.Windows.Forms.checkbox
  373.             $EmailAddress05.Location = new-object System.Drawing.Size(30,180)
  374.             $EmailAddress05.Size = new-object System.Drawing.Size(520,50)
  375.             $EmailAddress05.Text = "<@<domain>>"
  376.             $EmailAddress05.Checked = $False
  377.             $EmailAddress05.add_click($handler_button1_Click)
  378.             $AddressForm.Controls.Add($EmailAddress05)
  379.  
  380.             $EmailAddress06 = new-object System.Windows.Forms.checkbox
  381.             $EmailAddress06.Location = new-object System.Drawing.Size(30,220)
  382.             $EmailAddress06.Size = new-object System.Drawing.Size(520,50)
  383.             $EmailAddress06.Text = "@<domain>>"
  384.             $EmailAddress06.Checked = $False
  385.             $EmailAddress06.add_click($handler_button1_Click)
  386.             $AddressForm.Controls.Add($EmailAddress06)
  387.  
  388.             $EmailAddress07 = new-object System.Windows.Forms.checkbox
  389.             $EmailAddress07.Location = new-object System.Drawing.Size(30,260)
  390.             $EmailAddress07.Size = new-object System.Drawing.Size(520,50)
  391.             $EmailAddress07.Text = "@<domain>>"
  392.             $EmailAddress07.Checked = $False
  393.             $EmailAddress07.add_click($handler_button1_Click)
  394.             $AddressForm.Controls.Add($EmailAddress07)
  395.  
  396.             $EmailAddress08 = new-object System.Windows.Forms.checkbox
  397.             $EmailAddress08.Location = new-object System.Drawing.Size(30,300)
  398.             $EmailAddress08.Size = new-object System.Drawing.Size(520,50)
  399.             $EmailAddress08.Text = "@<domain>>"
  400.             $EmailAddress08.Checked = $False
  401.             $EmailAddress08.add_click($handler_button1_Click)
  402.             $AddressForm.Controls.Add($EmailAddress08)
  403.  
  404.             $EmailAddress09 = new-object System.Windows.Forms.checkbox
  405.             $EmailAddress09.Location = new-object System.Drawing.Size(30,340)
  406.             $EmailAddress09.Size = new-object System.Drawing.Size(520,50)
  407.             $EmailAddress09.Text = "@<domain>>"
  408.             $EmailAddress09.Checked = $False
  409.             $EmailAddress09.add_click($handler_button1_Click)
  410.             $AddressForm.Controls.Add($EmailAddress09)
  411.  
  412.             $EmailAddress10 = new-object System.Windows.Forms.checkbox
  413.             $EmailAddress10.Location = new-object System.Drawing.Size(30,380)
  414.             $EmailAddress10.Size = new-object System.Drawing.Size(520,50)
  415.             $EmailAddress10.Text = "@<domain>>"
  416.             $EmailAddress10.Checked = $False
  417.             $EmailAddress10.add_click($handler_button1_Click)
  418.             $AddressForm.Controls.Add($EmailAddress10)
  419.  
  420.             $EmailAddress11 = new-object System.Windows.Forms.checkbox
  421.             $EmailAddress11.Location = new-object System.Drawing.Size(30,420)
  422.             $EmailAddress11.Size = new-object System.Drawing.Size(520,50)
  423.             $EmailAddress11.Text = "@<domain>>"
  424.             $EmailAddress11.Checked = $False
  425.             $EmailAddress11.add_click($handler_button1_Click)
  426.             $AddressForm.Controls.Add($EmailAddress11)
  427.  
  428.             $EmailAddress12 = new-object System.Windows.Forms.checkbox
  429.             $EmailAddress12.Location = new-object System.Drawing.Size(30,460)
  430.             $EmailAddress12.Size = new-object System.Drawing.Size(520,50)
  431.             $EmailAddress12.Text = "@<domain>>"
  432.             $EmailAddress12.Checked = $False
  433.             $EmailAddress12.add_click($handler_button1_Click)
  434.             $AddressForm.Controls.Add($EmailAddress12)
  435.  
  436.             $EmailAddress13 = new-object System.Windows.Forms.checkbox
  437.             $EmailAddress13.Location = new-object System.Drawing.Size(30,500)
  438.             $EmailAddress13.Size = new-object System.Drawing.Size(520,50)
  439.             $EmailAddress13.Text = "@<domain>>"
  440.             $EmailAddress13.Checked = $False
  441.             $EmailAddress13.add_click($handler_button1_Click)
  442.             $AddressForm.Controls.Add($EmailAddress13)
  443.  
  444.             $EmailAddress14 = new-object System.Windows.Forms.checkbox
  445.             $EmailAddress14.Location = new-object System.Drawing.Size(30,540)
  446.             $EmailAddress14.Size = new-object System.Drawing.Size(520,50)
  447.             $EmailAddress14.Text = "@<domain>>"
  448.             $EmailAddress14.Checked = $False
  449.             $EmailAddress14.add_click($handler_button1_Click)
  450.             $AddressForm.Controls.Add($EmailAddress14)
  451.             #endregion EMAIL ADDRESS LIST
  452.             $btnTo = New-Object system.windows.Forms.Button
  453.             $btnTo.Text = "Populate To Field "
  454.             $btnTo.Width = 160
  455.             $btnTo.Height = 30
  456.             $btnTo.location = new-object system.drawing.point(30,600)
  457.             $btnTo.Font = "Microsoft Sans Serif,10"
  458.             $btnTo.Add_Click({$txtEmailTo.Text = $Script:AddressList -Join '; ';$AddressForm.Close()})
  459.             $btnTo.DialogResult=[System.Windows.Forms.DialogResult]::OK
  460.             $AddressForm.controls.Add($btnTo)
  461.  
  462.             $btnBCC = New-Object system.windows.Forms.Button
  463.             $btnBCC.Text = "Populate BCC Field"
  464.             $btnBCC.Width = 160
  465.             $btnBCC.Height = 30
  466.             $btnBCC.location = new-object system.drawing.point(190,600)
  467.             $btnBCC.Add_Click({$txtBCC.Text = $Script:AddressList -Join '; ';$AddressForm.Close()})
  468.             $btnBCC.Font = "Microsoft Sans Serif,10"
  469.             $btnBCC.DialogResult=[System.Windows.Forms.DialogResult]::OK
  470.             $AddressForm.controls.Add($btnBCC)
  471.  
  472.             $btnCancel = New-Object system.windows.Forms.Button
  473.             $btnCancel.Text = "Cancel"
  474.             $btnCancel.Width = 320
  475.             $btnCancel.Height = 30
  476.             $btnCancel.location = new-object system.drawing.point(30,640)
  477.             $btnCancel.Font = "Microsoft Sans Serif,10"
  478.             $btnCancel.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
  479.             $AddressForm.controls.Add($btnCancel)
  480.             $AddressForm.Add_Shown({$Addressform.Activate()})
  481.             $dialogResult = $Addressform.ShowDialog()
  482.         }
  483.         #endregion ADDRESS PICKER FORM & FUNCTION
  484.         #endregion DECLARE FUNCTIONS
  485. #region SWITCHES
  486.     #region PRIORITY SET
  487.         $radioButtons_CheckedChanged={
  488.             if ($rbNotificationTypeI.Checked -eq $True) {$lblPrioritySet.Text = $rbNotificationTypeI.Tag
  489.                                                         $lblPrioritySet.BackColor = ""}
  490.         elseif ($rbNotificationTypeW.Checked -eq $True) {$lblPrioritySet.Text = $rbNotificationTypeW.Tag
  491.                                                         $lblPrioritySet.BackColor = "Red"}
  492.         }
  493.         #endregion PRIORITY SET
  494.     #region OUTAGE TYPE
  495.         $radioButtons_CheckedChangedOutageType={
  496.                 if ($rbOutageTypeUN.Checked -eq $True) {$txtSubject.Text = $rbOutageTypeUN.Tag + " Outage"
  497.                                                         $script:outageTitle = $rbOutageTypeUN.Tag + " Outage"
  498.                                                         $rbGroupBoxOutage.BackColor = ""}
  499.             elseif ($rbOutageTypeSC.Checked -eq $True) {$txtSubject.Text = $rbOutageTypeSC.Tag + " Outage"
  500.                                                         $script:outageTitle = $rbOutageTypeSC.Tag + " Outage"
  501.                                                         $rbGroupBoxOutage.BackColor = ""}
  502.         }
  503.         #endregion OUTAGE TYPE
  504.     #region NOTIFICATION TYPE
  505.         $DropDown_CheckedChanged={
  506.             if      ($ddType.Text -eq "Informational")  {
  507.                                                     $lblAffectedServices.Text =     "Information"
  508.                                                     $lblOutage1.Text =              "Additional Information"
  509.                                                     $lblYou.Text =                  "What You Should Do"
  510.                                                     $lblAffectedServices.ReadOnly = $True
  511.                                                     $lblOutage1.ReadOnly =          $True
  512.                                                     $lblYou.ReadOnly =              $True
  513.                                                     $rbOutageTypeSC.Checked =       $False
  514.                                                     $txtSubject.Text =              ""
  515.                                                     $ddBanner.SelectedIndex =       0
  516.                                                     $ddBanner.Enabled =             $False
  517.                                                     $pbBanner.ImageLocation =       $script:BannerInformation
  518.                                                     $pbBanner.Image = [System.Drawing.Image]::Fromfile($script:BannerInformation)
  519.                                                     $txtOutage.Visible =            $True
  520.                                                     $ddBanner.Visible =             $False
  521.                                                     ForEach ($Control in $Form.Controls) {If ($Control.Tag -eq '1') {$control.visible = $False}}
  522.                                                     }
  523.             elseif  ($ddType.Text -eq "Warning")        {
  524.                                                     $lblAffectedServices.Text =     "Warning"
  525.                                                     $lblOutage1.Text =              "Information"
  526.                                                     $lblYou.Text =                  "What You Should Do"
  527.                                                     $lblAffectedServices.ReadOnly = $True
  528.                                                     $lblOutage1.ReadOnly =          $True
  529.                                                     $lblYou.ReadOnly =              $True
  530.                                                     $rbOutageTypeSC.Checked =       $False
  531.                                                     $txtSubject.Text =              ""
  532.                                                     $ddBanner.SelectedIndex =       1
  533.                                                     $ddBanner.Enabled =             $False
  534.                                                     $pbBanner.ImageLocation =       $script:BannerWarning
  535.                                                     $pbBanner.Image = [System.Drawing.Image]::Fromfile($script:BannerWarning)
  536.                                                     $txtOutage.Visible =            $True
  537.                                                     $ddBanner.Visible =             $False
  538.                                                     ForEach ($Control in $Form.Controls) {If ($Control.Tag -eq '1') {$control.visible = $False}}
  539.                                                     }
  540.             elseif  ($ddType.Text -eq "Outage")         {
  541.                                                     $lblAffectedServices.Text =     "Information"
  542.                                                     $lblOutage1.Text =              "Outage Window"
  543.                                                     $lblYou.Text =                  "What You Should Do"
  544.                                                     $lblAffectedServices.ReadOnly = $True
  545.                                                     $lblOutage1.ReadOnly =          $True
  546.                                                     $lblYou.ReadOnly =              $True
  547.                                                     $ddBanner.Enabled =             $False
  548.                                                     $ddBanner.SelectedIndex =       2
  549.                                                     $pbBanner.ImageLocation =       $script:BannerOutage
  550.                                                     $pbBanner.Image = [System.Drawing.Image]::Fromfile($script:BannerOutage)
  551.                                                     $txtOutage.Visible =            $False
  552.                                                     $ddBanner.Visible =             $False
  553.                                                     ForEach ($Control in $Form.Controls) {If ($Control.Tag -eq '1') {$control.visible = $True}}
  554.                                                     }
  555.             elseif  ($ddType.Text -eq "Custom")         {
  556.                                                     $lblAffectedServices.ReadOnly = $False
  557.                                                     $lblOutage1.ReadOnly =          $False
  558.                                                     $lblYou.ReadOnly =              $False
  559.                                                     $rbOutageTypeSC.Checked =       $False
  560.                                                     $ddBanner.Enabled =             $True
  561.                                                     $ddBanner.SelectedIndex =       0
  562.                                                     $txtSubject.Text =              ""
  563.                                                     $txtOutage.Visible =            $True
  564.                                                     $ddBanner.Visible =             $True
  565.                                                     ForEach ($Control in $Form.Controls) {If ($Control.Tag -eq '1') {$control.visible = $False}}
  566.                                                     }
  567.             }
  568.         #endregion NOTIFICATION TYPE
  569.     #region BANNER PICKER
  570.         $BannerDropDown_CheckedChanged={
  571.             if ($ddBanner.Text -eq "Informational") {
  572.                     $pbBanner.ImageLocation = "$script:BannerInformation"
  573.                     $pbBanner.Image = [System.Drawing.Image]::Fromfile("$script:BannerInformation")}
  574.             elseif ($ddBanner.Text -eq "Warning") {
  575.                     $pbBanner.ImageLocation = "$script:BannerWarning"
  576.                     $pbBanner.Image = [System.Drawing.Image]::Fromfile("$script:BannerWarning")}
  577.             elseif ($ddBanner.Text -eq "Outage") {
  578.                     $pbBanner.ImageLocation = "$script:BannerOutage"
  579.                     $pbBanner.Image = [System.Drawing.Image]::Fromfile("$script:BannerOutage")
  580.             }
  581.         }
  582.         #endregion BANNER PICKER
  583.     #region HIDE SECTIONS
  584.         $handler_button2_Click= {
  585.         if ($cbAffectedServices.Checked -eq $False) {$lblAffectedServices.Visible = $False
  586.                                                     $txtAffectedServices.Visible = $False}
  587.         else    {$lblAffectedServices.Visible = $True
  588.                 $txtAffectedServices.Visible = $True}
  589.         }
  590.         $handler_button3_Click= {
  591.         if ($cbOutage1.Checked -eq $False) {$lblOutage1.Visible = $False
  592.                                             $txtOutage.Visible = $False}
  593.         else    {$lblOutage1.Visible = $True
  594.                 $txtOutage.Visible = $True}
  595.         }
  596.         $handler_button4_Click= {
  597.         if ($cbYou.Checked -eq $False)  {$lblYou.Visible = $False
  598.                                         $txtYou.Visible = $False}
  599.         else    {$lblYou.Visible = $True
  600.                 $txtYou.Visible = $True}
  601.         }
  602.         #endregion HIDE SECTIONS
  603. #region FORM
  604.     Add-Type -AssemblyName System.Windows.Forms
  605.     $Form = New-Object system.Windows.Forms.Form
  606.     $Form.Text = "Form"
  607.     $Form.TopMost = $True
  608.     $Form.Width = 1000
  609.     $Form.Height = 1000
  610.     # $Form.BackColor = [System.Drawing.ColorTranslator]::FromHtml('#'+"3f3f3f")
  611.     $Form.KeyPreview = $True
  612.     $Form.Add_KeyDown({if ($_.KeyCode -eq "Enter")
  613.     {
  614.     # If {Enter} Do {Nothing}
  615.     }
  616.     })
  617.     $Form.Add_KeyDown({if ($_.KeyCode -eq "Escape")
  618.         {
  619.         $Form.Close()
  620.         }
  621.     })
  622.  
  623.     $ddType = new-object System.Windows.Forms.ComboBox
  624.     $ddType.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  625.     $ddType.Location = new-object System.Drawing.Size(10,10)
  626.     $ddType.Size = new-object System.Drawing.Size(130,30)
  627.     $ddType.Items.Add("Informational") | Out-Null
  628.     $ddType.Items.Add("Warning") | Out-Null
  629.     $ddType.Items.Add("Outage") | Out-Null
  630.     $ddType.Items.Add("Custom") | Out-Null
  631.     $ddType.SelectedIndex=0
  632.     $ddType.add_SelectedIndexChanged($DropDown_CheckedChanged)
  633.     $form.Controls.Add($ddType)
  634.  
  635.     $lblEmailTo = New-Object system.windows.Forms.Label
  636.     $lblEmailTo.Text = "To"
  637.     $lblEmailTo.AutoSize = $True
  638.     $lblEmailTo.Width = 25
  639.     $lblEmailTo.Height = 10
  640.     $lblEmailTo.location = new-object system.drawing.point(10,40)
  641.     $lblEmailTo.Font = "Microsoft Sans Serif,10"
  642.     $Form.controls.Add($lblEmailTo)
  643.  
  644.     $lblSubject = New-Object system.windows.Forms.Label
  645.     $lblSubject.Text = "Subject"
  646.     $lblSubject.AutoSize = $True
  647.     $lblSubject.Width = 25
  648.     $lblSubject.Height = 10
  649.     $lblSubject.location = new-object system.drawing.point(10,80)
  650.     $lblSubject.Font = "Microsoft Sans Serif,10"
  651.     $Form.controls.Add($lblSubject)
  652.  
  653.     $lblBCC = New-Object system.windows.Forms.Label
  654.     $lblBCC.Text = "BCC"
  655.     $lblBCC.AutoSize = $True
  656.     $lblBCC.Width = 25
  657.     $lblBCC.Height = 10
  658.     $lblBCC.location = new-object system.drawing.point(550,40)
  659.     $lblBCC.Font = "Microsoft Sans Serif,10"
  660.     $Form.controls.Add($lblBCC)
  661.  
  662.     $lblPriority = New-Object system.windows.Forms.Label
  663.     $lblPriority.Text = "Priority"
  664.     $lblPriority.AutoSize = $True
  665.     $lblPriority.Width = 25
  666.     $lblPriority.Height = 10
  667.     $lblPriority.location = new-object system.drawing.point(10,120)
  668.     $lblPriority.Font = "Microsoft Sans Serif,10"
  669.     $Form.controls.Add($lblPriority)
  670.  
  671.     $lblPrioritySet = New-Object system.windows.Forms.Label
  672.     $lblPrioritySet.Text = "Normal"
  673.     $lblPrioritySet.AutoSize = $True
  674.     $lblPrioritySet.Width = 25
  675.     $lblPrioritySet.Height = 10
  676.     $lblPrioritySet.location = new-object system.drawing.point(200,120)
  677.     $lblPrioritySet.Font = "Microsoft Sans Serif,10"
  678.     $Form.controls.Add($lblPrioritySet)
  679.  
  680.     $lblDate = New-Object system.windows.Forms.Label
  681.     $lblDate.Text = "Date"
  682.     $lblDate.AutoSize = $True
  683.     $lblDate.Width = 25
  684.     $lblDate.Height = 10
  685.     $lblDate.location = new-object system.drawing.point(550,80)
  686.     $lblDate.Font = "Microsoft Sans Serif,10"
  687.     $Form.controls.Add($lblDate)
  688.  
  689.     $cbAffectedServices = New-Object System.Windows.Forms.CheckBox
  690.     $cbAffectedServices.Location = New-Object System.Drawing.Point(10,160)
  691.     $cbAffectedServices.Height = 25
  692.     $cbAffectedServices.Width = 20
  693.     $cbAffectedServices.Checked = $True
  694.     $cbAffectedServices.add_click($handler_button2_Click)
  695.     $Form.controls.Add($cbAffectedServices)
  696.  
  697.     $lblAffectedServices = New-Object system.windows.Forms.RichTextBox
  698.     $lblAffectedServices.Text = "Information"
  699.     $lblAffectedServices.ReadOnly = $True
  700.     $lblAffectedServices.AutoSize = $True
  701.     $lblAffectedServices.Multiline = $False
  702.     $lblAffectedServices.Width = 155
  703.     $lblAffectedServices.Height = 22
  704.     $lblAffectedServices.location = new-object system.drawing.point(30,160)
  705.     $lblAffectedServices.Font = "Microsoft Sans Serif,10"
  706.     $Form.controls.Add($lblAffectedServices)
  707.  
  708.     $cbOutage1 = New-Object System.Windows.Forms.CheckBox
  709.     $cbOutage1.Location = New-Object System.Drawing.Point(10,380)
  710.     $cbOutage1.Height = 25
  711.     $cbOutage1.Width = 20
  712.     $cbOutage1.Checked = $True
  713.     $cbOutage1.add_click($handler_button3_Click)
  714.     $Form.controls.Add($cbOutage1)
  715.  
  716.     $lblOutage1 = New-Object system.windows.Forms.RichTextBox
  717.     $lblOutage1.Text = "Additional Information"
  718.     $lblOutage1.ReadOnly = $True
  719.     $lblOutage1.AutoSize = $True
  720.     $lblOutage1.Multiline = $False
  721.     $lblOutage1.Width = 155
  722.     $lblOutage1.Height = 22
  723.     $lblOutage1.location = new-object system.drawing.point(30,380)
  724.     $lblOutage1.Font = "Microsoft Sans Serif,10"
  725.     $Form.controls.Add($lblOutage1)
  726.  
  727.     $lblOutageType = New-Object System.Windows.Forms.RadioButton
  728.     $lblOutageType.Text = "Additional Information"
  729.     $lblOutageType.AutoSize = $True
  730.     $lblOutageType.Width = 175
  731.     $lblOutageType.Height = 10
  732.     $lblOutageType.location = new-object system.drawing.point(10,380)
  733.     $lblOutageType.Font = "Microsoft Sans Serif,10"
  734.     $Form.controls.Add($lblOutage1)
  735.  
  736.     $rbOutageTypeUN = New-Object system.windows.Forms.RadioButton
  737.     $rbOutageTypeUN.Text = "Unscheduled"
  738.     $rbOutageTypeUN.Tag = 'Unscheduled'
  739.     $rbOutageTypeUN.AutoSize = $True
  740.     $rbOutageTypeUN.Width = 100
  741.     $rbOutageTypeUN.Height = 22
  742.     $rbOutageTypeUN.location = new-object system.drawing.point(10,10)
  743.     $rbOutageTypeUN.Font = "Microsoft Sans Serif,10"
  744.     $rbOutageTypeUN.add_click($radioButtons_CheckedChangedOutageType)
  745.  
  746.     $rbOutageTypeSC = New-Object system.windows.Forms.RadioButton
  747.     $rbOutageTypeSC.Text = "Scheduled"
  748.     $rbOutageTypeSC.Tag = 'Scheduled'
  749.     $rbOutageTypeSC.AutoSize = $True
  750.     $rbOutageTypeSC.Width = 100
  751.     $rbOutageTypeSC.Height = 22
  752.     $rbOutageTypeSC.location = new-object system.drawing.point(200,10)
  753.     $rbOutageTypeSC.Font = "Microsoft Sans Serif,10"
  754.     $rbOutageTypeSC.add_click($radioButtons_CheckedChangedOutageType)
  755.  
  756.     $rbGroupBoxOutage = New-Object Windows.Forms.Panel
  757.     $rbGroupBoxOutage.Text = ""
  758.     $rbGroupBoxOutage.Visible = $False
  759.     $rbGroupBoxOutage.BackColor = "Red"
  760.     $rbGroupBoxOutage.Left = 200
  761.     $rbGroupBoxOutage.Top = 369
  762.     $rbGroupBoxOutage.Width = 300
  763.     $rbGroupBoxOutage.Height = 40
  764.     $rbGroupBoxOutage.Controls.Add($rbOutageTypeUN)
  765.     $rbGroupBoxOutage.Controls.Add($rbOutageTypeSC)
  766.     $rbGroupBoxOutage.Tag = '1'
  767.     $form.controls.add($rbGroupboxOutage)
  768.  
  769.     $lblOutageStartDate = New-Object system.windows.Forms.Label
  770.     $lblOutageStartDate.Text = "Start Date"
  771.     $lblOutageStartDate.Visible = $False
  772.     $lblOutageStartDate.AutoSize = $True
  773.     $lblOutageStartDate.Width = 175
  774.     $lblOutageStartDate.Height = 10
  775.     $lblOutageStartDate.location = new-object system.drawing.point(10,420)
  776.     $lblOutageStartDate.Font = "Microsoft Sans Serif,10"
  777.     $lblOutageStartDate.Tag = '1'
  778.     $Form.controls.Add($lblOutageStartDate)
  779.  
  780.     $lblOutageStartTime = New-Object system.windows.Forms.Label
  781.     $lblOutageStartTime.Text = "Start Time"
  782.     $lblOutageStartTime.Visible = $False
  783.     $lblOutageStartTime.AutoSize = $True
  784.     $lblOutageStartTime.Width = 175
  785.     $lblOutageStartTime.Height = 10
  786.     $lblOutageStartTime.location = new-object system.drawing.point(10,460)
  787.     $lblOutageStartTime.Font = "Microsoft Sans Serif,10"
  788.     $lblOutageStartTime.Tag = '1'
  789.     $Form.controls.Add($lblOutageStartTime)
  790.  
  791.     $lblOutageEndDate = New-Object system.windows.Forms.Label
  792.     $lblOutageEndDate.Text = "End Date"
  793.     $lblOutageEndDate.Visible = $False
  794.     $lblOutageEndDate.AutoSize = $True
  795.     $lblOutageEndDate.Width = 175
  796.     $lblOutageEndDate.Height = 10
  797.     $lblOutageEndDate.location = new-object system.drawing.point(10,500)
  798.     $lblOutageEndDate.Font = "Microsoft Sans Serif,10"
  799.     $lblOutageEndDate.Tag = '1'
  800.     $Form.controls.Add($lblOutageEndDate)
  801.  
  802.     $lblOutageEndTime = New-Object system.windows.Forms.Label
  803.     $lblOutageEndTime.Text = "End Time"
  804.     $lblOutageEndTime.Visible = $False
  805.     $lblOutageEndTime.AutoSize = $True
  806.     $lblOutageEndTime.Width = 175
  807.     $lblOutageEndTime.Height = 10
  808.     $lblOutageEndTime.location = new-object system.drawing.point(10,540)
  809.     $lblOutageEndTime.Font = "Microsoft Sans Serif,10"
  810.     $lblOutageEndTime.Tag = '1'
  811.     $Form.controls.Add($lblOutageEndTime)
  812.  
  813.     $cbYou = New-Object System.Windows.Forms.CheckBox
  814.     $cbYou.Location = New-Object System.Drawing.Point(10,600)
  815.     $cbYou.Height = 25
  816.     $cbYou.Width = 20
  817.     $cbYou.Checked = $True
  818.     $cbYou.add_click($handler_button4_Click)
  819.     $Form.controls.Add($cbYou)
  820.  
  821.     $lblYou = New-Object system.windows.Forms.RichTextBox
  822.     $lblYou.Text = "What You Should Do"
  823.     $lblYou.ReadOnly = $True
  824.     $lblYou.AutoSize = $True
  825.     $lblYou.Multiline = $False
  826.     $lblYou.Width = 155
  827.     $lblYou.Height = 22
  828.     $lblYou.location = new-object system.drawing.point(30,600)
  829.     $lblYou.Font = "Microsoft Sans Serif,10"
  830.     $Form.controls.Add($lblYou)
  831.  
  832.     $lblBanner = New-Object System.Windows.Forms.Label
  833.     $lblBanner.Text = "Email Body Banner"
  834.     $lblBanner.AutoSize = $True
  835.     $lblBanner.Width = 175
  836.     $lblBanner.Height = 10
  837.     $lblBanner.location = new-object system.drawing.point(10,720)
  838.     $lblBanner.Font = "Microsoft Sans Serif,10"
  839.     $Form.controls.Add($lblBanner)
  840.  
  841.     $ddBanner = New-Object System.Windows.Forms.ComboBox
  842.     $ddBanner.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  843.     $ddBanner.Location = new-object System.Drawing.Size(10,740)
  844.     $ddBanner.Size = new-object System.Drawing.Size(130,30)
  845.     $ddBanner.Enabled = $False
  846.     $ddBanner.Items.Add("Informational") | Out-Null
  847.     $ddBanner.Items.Add("Warning") | Out-Null
  848.     $ddBanner.Items.Add("Outage") | Out-Null
  849.     $ddBanner.SelectedIndex=0
  850.     $ddBanner.Visible = $False
  851.     $ddBanner.add_SelectedIndexChanged($BannerDropDown_CheckedChanged)
  852.     $form.Controls.Add($ddBanner)
  853.  
  854.     $txtEmailTo = New-Object system.windows.Forms.RichTextBox
  855.     $txtEmailTo.Multiline = $False
  856.     $txtEmailTo.Width = 300
  857.     $txtEmailTo.Height = 22
  858.     $txtEmailTo.location = new-object system.drawing.point(200,40)
  859.     $txtEmailTo.Font = "Microsoft Sans Serif,10"
  860.     $txtEmailTo.Text = ""
  861.     $Form.controls.Add($txtEmailTo)
  862.  
  863.     $txtSubject = New-Object system.windows.Forms.RichTextBox
  864.     $txtSubject.Multiline = $False
  865.     $txtSubject.Width = 300
  866.     $txtSubject.Height = 22
  867.     $txtSubject.location = new-object system.drawing.point(200,80)
  868.     $txtSubject.Font = "Microsoft Sans Serif,10"
  869.     $txtSubject.Text = "Test"
  870.     $Form.controls.Add($txtSubject)
  871.  
  872.     $txtBCC = New-Object system.windows.Forms.RichTextBox
  873.     $txtBCC.Multiline = $False
  874.     $txtBCC.Width = 200
  875.     $txtBCC.Height = 22
  876.     $txtBCC.location = new-object system.drawing.point(590,40)
  877.     $txtBCC.Font = "Microsoft Sans Serif,10"
  878.     $txtBCC.Text = ""
  879.     $Form.controls.Add($txtBCC)
  880.  
  881.     $txtDate = New-Object system.windows.Forms.RichTextBox
  882.     $txtDate.Multiline = $False
  883.     $txtDate.Width = 200
  884.     $txtDate.Height = 22
  885.     $txtDate.location = new-object system.drawing.point(590,80)
  886.     $txtDate.Font = "Microsoft Sans Serif,10"
  887.     $txtDate.Text = Get-DateOrdinalSuffix1 ($DateFormattedTxtBox)
  888.     $Form.controls.Add($txtDate)
  889.  
  890.     $txtAffectedServices = New-Object System.Windows.Forms.RichTextBox
  891.     $txtAffectedServices.Text = 'Test1'
  892.     $txtAffectedServices.Width = 300
  893.     $txtAffectedServices.Height = 200
  894.     $txtAffectedServices.Multiline = $True
  895.     $txtAffectedServices.location = new-object system.drawing.point(200,160)
  896.     $txtAffectedServices.Font = "Microsoft Sans Serif,10"
  897.     $Form.controls.Add($txtAffectedServices)
  898.  
  899.     $txtOutage = New-Object system.windows.Forms.RichTextBox
  900.     $txtOutage.Width = 300
  901.     $txtOutage.Height = 200
  902.     $txtOutage.Visible = $True
  903.     $txtOutage.Multiline = $True
  904.     $txtOutage.location = new-object system.drawing.point(200,380)
  905.     $txtOutage.Font = "Microsoft Sans Serif,10"
  906.     $txtOutage.Text = 'Test'
  907.     $Form.controls.Add($txtOutage)
  908.  
  909.     $txtOutageStartDate = New-Object system.windows.Forms.RichTextBox
  910.     $txtOutageStartDate.Width = 300
  911.     $txtOutageStartDate.Height = 22
  912.     $txtOutageStartDate.Visible = $False
  913.     $txtOutageStartDate.Multiline = $False
  914.     $txtOutageStartDate.location = new-object system.drawing.point(200,420)
  915.     $txtOutageStartDate.Font = "Microsoft Sans Serif,10"
  916.     $txtOutageStartDate.Text = 'Double click date on Calendar'
  917.     $txtOutageStartDate.Tag = '1'
  918.     $Form.controls.Add($txtOutageStartDate)
  919.  
  920.     $ddOutageStartTimeHH = New-Object system.windows.Forms.ComboBox
  921.     $ddOutageStartTimeHH.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  922.     $ddOutageStartTimeHH.Width = 40
  923.     $ddOutageStartTimeHH.Height = 22
  924.     $ddOutageStartTimeHH.Items.Add("01") | Out-Null
  925.     $ddOutageStartTimeHH.Items.Add("02") | Out-Null
  926.     $ddOutageStartTimeHH.Items.Add("03") | Out-Null
  927.     $ddOutageStartTimeHH.Items.Add("04") | Out-Null
  928.     $ddOutageStartTimeHH.Items.Add("05") | Out-Null
  929.     $ddOutageStartTimeHH.Items.Add("06") | Out-Null
  930.     $ddOutageStartTimeHH.Items.Add("07") | Out-Null
  931.     $ddOutageStartTimeHH.Items.Add("08") | Out-Null
  932.     $ddOutageStartTimeHH.Items.Add("09") | Out-Null
  933.     $ddOutageStartTimeHH.Items.Add("10") | Out-Null
  934.     $ddOutageStartTimeHH.Items.Add("11") | Out-Null
  935.     $ddOutageStartTimeHH.Items.Add("12") | Out-Null
  936.     $ddOutageStartTimeHH.Visible = $False
  937.     $ddOutageStartTimeHH.DropDownHeight = 200
  938.     $ddOutageStartTimeHH.location = new-object system.drawing.point(200,460)
  939.     $ddOutageStartTimeHH.Font = "Microsoft Sans Serif,10"
  940.     $ddOutageStartTimeHH.Tag = '1'
  941.     $Form.controls.Add($ddOutageStartTimeHH)
  942.  
  943.     $ddOutageStartTimeMM = New-Object system.windows.Forms.ComboBox
  944.     $ddOutageStartTimeMM.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  945.     $ddOutageStartTimeMM.Width = 40
  946.     $ddOutageStartTimeMM.Height = 22
  947.     $ddOutageStartTimeMM.Items.Add("00") | Out-Null
  948.     $ddOutageStartTimeMM.Items.Add("15") | Out-Null
  949.     $ddOutageStartTimeMM.Items.Add("30") | Out-Null
  950.     $ddOutageStartTimeMM.Items.Add("45") | Out-Null
  951.     $ddOutageStartTimeMM.Visible = $False
  952.     $ddOutageStartTimeMM.DropDownHeight = 200
  953.     $ddOutageStartTimeMM.AutoSize = $True
  954.     $ddOutageStartTimeMM.location = new-object system.drawing.point(240,460)
  955.     $ddOutageStartTimeMM.Font = "Microsoft Sans Serif,10"
  956.     $ddOutageStartTimeMM.Tag = '1'
  957.     $Form.controls.Add($ddOutageStartTimeMM)
  958.  
  959.     $rbOutageStartTimeAM = New-Object system.windows.Forms.RadioButton
  960.     $rbOutageStartTimeAM.Text = "AM"
  961.     $rbOutageStartTimeAM.AutoSize = $True
  962.     $rbOutageStartTimeAM.Width = 15
  963.     $rbOutageStartTimeAM.Height = 22
  964.     $rbOutageStartTimeAM.location = new-object system.drawing.point(10,10)
  965.     $rbOutageStartTimeAM.Font = "Microsoft Sans Serif,10"
  966.     # $rbOutageStartTimeAM.add_click($radioButtons_CheckedChangedStartAMPM)
  967.  
  968.     $rbOutageStartTimePM = New-Object system.windows.Forms.RadioButton
  969.     $rbOutageStartTimePM.Text = "PM"
  970.     $rbOutageStartTimePM.AutoSize = $True
  971.     $rbOutageStartTimePM.Checked = $True
  972.     $rbOutageStartTimePM.Width = 15
  973.     $rbOutageStartTimePM.Height = 22
  974.     $rbOutageStartTimePM.location = new-object system.drawing.point(55,10)
  975.     $rbOutageStartTimePM.Font = "Microsoft Sans Serif,10"
  976.     # $rbOutageStartTimePM.add_click($radioButtons_CheckedChangedStartAMPM)
  977.  
  978.     $rbGroupBoxStartAMPM = New-Object Windows.Forms.Panel
  979.     $rbGroupBoxStartAMPM.Text = ""
  980.     $rbGroupBoxStartAMPM.Visible = $False
  981.     $rbGroupBoxStartAMPM.Left = 280
  982.     $rbGroupBoxStartAMPM.Top = 452
  983.     $rbGroupBoxStartAMPM.Width = 100
  984.     $rbGroupBoxStartAMPM.Height = 30
  985.     $rbGroupBoxStartAMPM.Controls.Add($rbOutageStartTimeAM)
  986.     $rbGroupBoxStartAMPM.Controls.Add($rbOutageStartTimePM)
  987.     $rbGroupBoxStartAMPM.Tag = '1'
  988.     $form.controls.add($rbGroupBoxStartAMPM)
  989.  
  990.     $txtOutageEndDate = New-Object system.windows.Forms.RichTextBox
  991.     $txtOutageEndDate.Width = 300
  992.     $txtOutageEndDate.Height = 22
  993.     $txtOutageEndDate.Visible = $False
  994.     $txtOutageEndDate.Multiline = $False
  995.     $txtOutageEndDate.location = new-object system.drawing.point(200,500)
  996.     $txtOutageEndDate.Font = "Microsoft Sans Serif,10"
  997.     $txtOutageEndDate.Text = 'Double click date on Calendar'
  998.     $txtOutageEndDate.Tag = '1'
  999.     $Form.controls.Add($txtOutageEndDate)
  1000.  
  1001.     $ddOutageEndTimeHH = New-Object system.windows.Forms.ComboBox
  1002.     $ddOutageEndTimeHH.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  1003.     $ddOutageEndTimeHH.Width = 40
  1004.     $ddOutageEndTimeHH.Height = 22
  1005.     $ddOutageEndTimeHH.Items.Add("01") | Out-Null
  1006.     $ddOutageEndTimeHH.Items.Add("02") | Out-Null
  1007.     $ddOutageEndTimeHH.Items.Add("03") | Out-Null
  1008.     $ddOutageEndTimeHH.Items.Add("04") | Out-Null
  1009.     $ddOutageEndTimeHH.Items.Add("05") | Out-Null
  1010.     $ddOutageEndTimeHH.Items.Add("06") | Out-Null
  1011.     $ddOutageEndTimeHH.Items.Add("07") | Out-Null
  1012.     $ddOutageEndTimeHH.Items.Add("08") | Out-Null
  1013.     $ddOutageEndTimeHH.Items.Add("09") | Out-Null
  1014.     $ddOutageEndTimeHH.Items.Add("10") | Out-Null
  1015.     $ddOutageEndTimeHH.Items.Add("11") | Out-Null
  1016.     $ddOutageEndTimeHH.Items.Add("12") | Out-Null
  1017.     $ddOutageEndTimeHH.Visible = $False
  1018.     $ddOutageEndTimeHH.DropDownHeight = 200
  1019.     $ddOutageEndTimeHH.AutoSize = $True
  1020.     $ddOutageEndTimeHH.location = new-object system.drawing.point(200,540)
  1021.     $ddOutageEndTimeHH.Font = "Microsoft Sans Serif,10"
  1022.     $ddOutageEndTimeHH.Tag = '1'
  1023.     $Form.controls.Add($ddOutageEndTimeHH)
  1024.  
  1025.     $ddOutageEndTimeMM = New-Object system.windows.Forms.ComboBox
  1026.     $ddOutageEndTimeMM.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  1027.     $ddOutageEndTimeMM.Width = 40
  1028.     $ddOutageEndTimeMM.Height = 22
  1029.     $ddOutageEndTimeMM.Items.Add("00") | Out-Null
  1030.     $ddOutageEndTimeMM.Items.Add("15") | Out-Null
  1031.     $ddOutageEndTimeMM.Items.Add("30") | Out-Null
  1032.     $ddOutageEndTimeMM.Items.Add("45") | Out-Null
  1033.     $ddOutageEndTimeMM.Visible = $False
  1034.     $ddOutageEndTimeMM.DropDownHeight = 200
  1035.     $ddOutageEndTimeMM.AutoSize = $True
  1036.     $ddOutageEndTimeMM.location = new-object system.drawing.point(240,540)
  1037.     $ddOutageEndTimeMM.Font = "Microsoft Sans Serif,10"
  1038.     $ddOutageEndTimeMM.Tag = '1'
  1039.     $Form.controls.Add($ddOutageEndTimeMM)
  1040.  
  1041.     $rbOutageEndTimeAM = New-Object system.windows.Forms.RadioButton
  1042.     $rbOutageEndTimeAM.Text = "AM"
  1043.     $rbOutageEndTimeAM.AutoSize = $True
  1044.     $rbOutageEndTimeAM.Width = 10
  1045.     $rbOutageEndTimeAM.Height = 22
  1046.     $rbOutageEndTimeAM.location = new-object system.drawing.point(10,10)
  1047.     $rbOutageEndTimeAM.Font = "Microsoft Sans Serif,10"
  1048.     # $rbOutageEndTimeAM.add_click($radioButtons_CheckedChangedEndAMPM)
  1049.  
  1050.     $rbOutageEndTimePM = New-Object system.windows.Forms.RadioButton
  1051.     $rbOutageEndTimePM.Text = "PM"
  1052.     $rbOutageEndTimePM.AutoSize = $True
  1053.     $rbOutageEndTimePM.Checked = $True
  1054.     $rbOutageEndTimePM.Width = 15
  1055.     $rbOutageEndTimePM.Height = 22
  1056.     $rbOutageEndTimePM.location = new-object system.drawing.point(55,10)
  1057.     $rbOutageEndTimePM.Font = "Microsoft Sans Serif,10"
  1058.     # $rbOutageEndTimePM.add_click($radioButtons_CheckedChangedEndAMPM)
  1059.  
  1060.     $rbGroupBoxEndAMPM = New-Object Windows.Forms.Panel
  1061.     $rbGroupBoxEndAMPM.Text = ""
  1062.     $rbGroupBoxEndAMPM.Visible = $False
  1063.     $rbGroupBoxEndAMPM.Left = 280
  1064.     $rbGroupBoxEndAMPM.Top = 532
  1065.     $rbGroupBoxEndAMPM.Width = 100
  1066.     $rbGroupBoxEndAMPM.Height = 30
  1067.     $rbGroupBoxEndAMPM.Controls.Add($rbOutageEndTimeAM)
  1068.     $rbGroupBoxEndAMPM.Controls.Add($rbOutageEndTimePM)
  1069.     $rbGroupBoxEndAMPM.Tag = '1'
  1070.     $form.controls.add($rbGroupBoxEndAMPM)
  1071.  
  1072.     $txtYou = New-Object system.windows.Forms.RichTextBox
  1073.     $txtYou.Width = 300
  1074.     $txtYou.Height = 100
  1075.     $txtYou.Multiline = $True
  1076.     $txtYou.location = new-object system.drawing.point(200,600)
  1077.     $txtYou.Font = "Microsoft Sans Serif,10"
  1078.     $txtYou.Text ="Any issues please contact IT Support"
  1079.     $Form.controls.Add($txtYou)
  1080.  
  1081.     $pbBanner = New-Object System.Windows.Forms.PictureBox
  1082.     $pbBanner.Width = 500
  1083.     $pbBanner.Height = 140
  1084.     $pbBanner.location = new-object system.drawing.point(200,720)
  1085.     $pbBanner.ImageLocation = "$script:BannerInformation"
  1086.     $pbBanner.Image = [System.Drawing.Image]::Fromfile("$script:BannerInformation")
  1087.     $Form.controls.Add($pbBanner)
  1088.  
  1089.     $ddSection1 = new-object System.Windows.Forms.ComboBox
  1090.     $ddSection1.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  1091.     $ddSection1.Location = new-object System.Drawing.Size(550,160)
  1092.     $ddSection1.Size = new-object System.Drawing.Size(30,21)
  1093.     $ddSection1.Items.Add("1") | Out-Null
  1094.     $ddSection1.Items.Add("2") | Out-Null
  1095.     $ddSection1.Items.Add("3") | Out-Null
  1096.     $ddSection1.SelectedIndex=0
  1097.     $form.Controls.Add($ddSection1)
  1098.  
  1099.     $ddSection2 = new-object System.Windows.Forms.ComboBox
  1100.     $ddSection2.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  1101.     $ddSection2.Location = new-object System.Drawing.Size(550,181)
  1102.     $ddSection2.Size = new-object System.Drawing.Size(30,21)
  1103.     $ddSection2.Items.Add("1") | Out-Null
  1104.     $ddSection2.Items.Add("2") | Out-Null
  1105.     $ddSection2.Items.Add("3") | Out-Null
  1106.     $ddSection2.SelectedIndex=0
  1107.     $ddSection2.Tag = ""
  1108.     $form.Controls.Add($ddSection2)
  1109.  
  1110.     $ddSection3 = new-object System.Windows.Forms.ComboBox
  1111.     $ddSection3.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  1112.     $ddSection3.Location = new-object System.Drawing.Size(550,202)
  1113.     $ddSection3.Size = new-object System.Drawing.Size(30,21)
  1114.     $ddSection3.Items.Add("1") | Out-Null
  1115.     $ddSection3.Items.Add("2") | Out-Null
  1116.     $ddSection3.Items.Add("3") | Out-Null
  1117.     $ddSection3.Tag = ""
  1118.     $ddSection3.SelectedIndex=0
  1119.     $form.Controls.Add($ddSection3)
  1120.  
  1121.     $ddSection4 = new-object System.Windows.Forms.ComboBox
  1122.     $ddSection4.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  1123.     $ddSection4.Location = new-object System.Drawing.Size(550,223)
  1124.     $ddSection4.Size = new-object System.Drawing.Size(30,21)
  1125.     $ddSection4.Items.Add("1") | Out-Null
  1126.     $ddSection4.Items.Add("2") | Out-Null
  1127.     $ddSection4.Items.Add("3") | Out-Null
  1128.     $ddSection4.SelectedIndex=0
  1129.     $ddSection4.Tag = ""
  1130.     $form.Controls.Add($ddSection4)
  1131.  
  1132.     $ddSection5 = new-object System.Windows.Forms.ComboBox
  1133.     $ddSection5.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
  1134.     $ddSection5.Location = new-object System.Drawing.Size(550,244)
  1135.     $ddSection5.Size = new-object System.Drawing.Size(30,21)
  1136.     $ddSection5.Items.Add("1") | Out-Null
  1137.     $ddSection5.Items.Add("2") | Out-Null
  1138.     $ddSection5.Items.Add("3") | Out-Null
  1139.     $ddSection5.SelectedIndex=0
  1140.     $ddSection5.Tag = ""
  1141.     $form.Controls.Add($ddSection5)
  1142.  
  1143.     $txtOutageIMG1 = New-Object system.windows.Forms.ListBox
  1144.     $txtOutageIMG1.Width = 370
  1145.     $txtOutageIMG1.Height = 105
  1146.     $txtOutageIMG1.location = new-object system.drawing.point(580,160)
  1147.     $txtOutageIMG1.Font = "Microsoft Sans Serif,12"
  1148.     $Form.controls.Add($txtOutageIMG1)
  1149.  
  1150.     $txtOutageAtt = New-Object system.windows.Forms.ListBox
  1151.     $txtOutageAtt.Width = 400
  1152.     $txtOutageAtt.Height = 85
  1153.     $txtOutageAtt.location = new-object system.drawing.point(550,280)
  1154.     $txtOutageAtt.Font = "Microsoft Sans Serif,10"
  1155.     $Form.controls.Add($txtOutageAtt)
  1156.  
  1157.     $rbNotificationTypeI = New-Object system.windows.Forms.RadioButton
  1158.     $rbNotificationTypeI.Text = "Normal"
  1159.     $rbNotificationTypeI.Tag= 'Normal'
  1160.     $rbNotificationTypeI.AutoSize = $True
  1161.     $rbNotificationTypeI.Width = 100
  1162.     $rbNotificationTypeI.Height = 22
  1163.     $rbNotificationTypeI.location = new-object system.drawing.point(10,20)
  1164.     $rbNotificationTypeI.Font = "Microsoft Sans Serif,10"
  1165.     $rbNotificationTypeI.Checked = $True
  1166.     $rbNotificationTypeI.add_click($radioButtons_CheckedChanged)
  1167.  
  1168.     $rbNotificationTypeW = New-Object system.windows.Forms.RadioButton
  1169.     $rbNotificationTypeW.Text = "High"
  1170.     $rbNotificationTypeW.AutoSize = $True
  1171.     $rbNotificationTypeW.Tag= 'High'
  1172.     $rbNotificationTypeW.Width = 100
  1173.     $rbNotificationTypeW.Height = 22
  1174.     $rbNotificationTypeW.location = new-object system.drawing.point(10,40)
  1175.     $rbNotificationTypeW.Font = "Microsoft Sans Serif,10"
  1176.     $rbNotificationTypeW.add_click($radioButtons_CheckedChanged)
  1177.  
  1178.     $rbGroupBox = New-Object Windows.Forms.GroupBox
  1179.     $rbGroupBox.Text = "Notification Priority"
  1180.     $rbGroupBox.Left = 810
  1181.     $rbGroupBox.Top = 35
  1182.     $rbGroupBox.Width = 150
  1183.     $rbGroupBox.Height = 70
  1184.     $rbGroupBox.Controls.Add($rbNotificationTypeI)
  1185.     $rbGroupBox.Controls.Add($rbNotificationTypeW)
  1186.     $form.controls.add($rbGroupbox)
  1187.  
  1188.     $btnSend = New-Object system.windows.Forms.Button
  1189.     $btnSend.Text = "Send"
  1190.     $btnSend.Width = 60
  1191.     $btnSend.Height = 30
  1192.     $btnSend.Visible = $False
  1193.     $btnSend.location = new-object system.drawing.point(800,680)
  1194.     $btnSend.Font = "Microsoft Sans Serif,10"
  1195.     $btnSend.PerformClick()
  1196.     $btnSend.DialogResult=[System.Windows.Forms.DialogResult]::OK
  1197.     $Form.controls.Add($btnSend)
  1198.  
  1199.     $btnPeerReview = New-Object system.windows.Forms.Button
  1200.     $btnPeerReview.Text = "Peer Review"
  1201.     $btnPeerReview.Width = 100
  1202.     $btnPeerReview.Height = 30
  1203.     $btnPeerReview.location = new-object system.drawing.point(700,680)
  1204.     $btnPeerReview.Font = "Microsoft Sans Serif,10"
  1205.     $btnPeerReview.PerformClick()
  1206.     $btnPeerReview.Add_Click({Send-Email -PeerReview "True"})
  1207.     $Form.controls.Add($btnPeerReview)
  1208.  
  1209.     $btnCancel = New-Object system.windows.Forms.Button
  1210.     $btnCancel.Text = "Cancel"
  1211.     $btnCancel.Width = 60
  1212.     $btnCancel.Height = 30
  1213.     $btnCancel.location = new-object system.drawing.point(880,680)
  1214.     $btnCancel.Font = "Microsoft Sans Serif,10"
  1215.     $btnCancel.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
  1216.     $Form.controls.Add($btnCancel)
  1217.  
  1218.     $btnBrowseImg = New-Object system.windows.Forms.Button
  1219.     $btnBrowseImg.Text = "Image Picker"
  1220.     $btnBrowseImg.Width = 200
  1221.     $btnBrowseImg.Height = 30
  1222.     $btnBrowseImg.location = new-object system.drawing.point(550,120)
  1223.     $btnBrowseImg.Font = "Microsoft Sans Serif,10"
  1224.     $btnBrowseImg.Add_Click({Get-Filename})
  1225.     $Form.controls.Add($btnBrowseImg)
  1226.  
  1227.     $btnBrowseAtt = New-Object system.windows.Forms.Button
  1228.     $btnBrowseAtt.Text = "Attachment Picker"
  1229.     $btnBrowseAtt.Width = 200
  1230.     $btnBrowseAtt.Height = 30
  1231.     $btnBrowseAtt.location = new-object system.drawing.point(750,120)
  1232.     $btnBrowseAtt.Font = "Microsoft Sans Serif,10"
  1233.     $btnBrowseAtt.Add_Click({Get-FilenameDoc})
  1234.     $Form.controls.Add($btnBrowseAtt)
  1235.  
  1236.     #region CALENDAR
  1237.         $cal = New-Object Windows.Forms.MonthCalendar;
  1238.         $cal.SetDate($DateSelected);
  1239.         $cal.TodayDate = $TodayDate;
  1240.             if($SelectionCount -lt 1){$SelectionCount = [int]::MaxValue;}
  1241.         $cal.MaxSelectionCount = $SelectionCount;
  1242.         $cal.MinDate = $MinDate;
  1243.         $cal.MaxDate = $MaxDate;
  1244.         $cal.ScrollChange = $ScrollBy;
  1245.         $cal.ShowTodayCircle = $True;
  1246.             if($FirstDayofWeek -eq -1){$FirstDayofWeek = [System.Windows.Forms.Day]::Default}
  1247.         $cal.FirstDayofWeek = [System.Windows.Forms.Day]$FirstDayofWeek;
  1248.         $cal.ShowWeekNumbers = $WeekNumbers;
  1249.         $cal.location = new-object system.drawing.point(570,370)
  1250.             if($NoTodayCircle){$cal.ShowTodayCircle = $False}
  1251.         switch -regex ($DisplayMode)
  1252.         {
  1253.             "^1$" {$cal.CalendarDimensions = "1,1"}
  1254.             "^2$" {$cal.CalendarDimensions = "2,1"}
  1255.             "^3$" { $cal.CalendarDimensions = "3,1"}
  1256.             "^4$" {$cal.CalendarDimensions = "2,2"}
  1257.             "^[56]$" {$cal.CalendarDimensions = "3,2"}
  1258.             "^[78]$" {$cal.CalendarDimensions = "4,2"}
  1259.             "^9$" {$cal.CalendarDimensions = "3,3"}
  1260.             "^1[012]$" {$cal.CalendarDimensions = "4,3"}
  1261.             "^16$" {$cal.CalendarDimensions = "4,4"}
  1262.             default {$cal.CalendarDimensions = "4,3"}
  1263.         }
  1264.  
  1265.         $Global:lastClick = (Get-Date)
  1266.         $cal.Add_DateSelected({
  1267.  
  1268.             if ((Get-Date) -lt $Global:lastClick.AddSeconds(1) -and $Global:lastDate.Start.Equals($cal.SelectionRange.Start) -and $Global:lastDate.End.Equals($cal.SelectionRange.End))
  1269.             {
  1270.                 Get-SuffixAndClipboard
  1271.             }
  1272.             $Global:lastDate = $cal.SelectionRange
  1273.             $Global:lastClick = Get-Date
  1274.         })
  1275.  
  1276.         $form.Controls.add($cal)
  1277.     #endregion CALENDAR
  1278.  
  1279.     $btnEmailTo = New-Object system.windows.Forms.Button
  1280.     $btnEmailTo.Text = "Address Picker"
  1281.     $btnEmailTo.Width = 200
  1282.     $btnEmailTo.Height = 25
  1283.     $btnEmailTo.location = new-object system.drawing.point(250,10)
  1284.     $btnEmailTo.Font = "Microsoft Sans Serif,10"
  1285.     $btnEmailTo.Add_Click({Get-Addresses})
  1286.     $Form.controls.Add($btnEmailTo)
  1287.  
  1288.     $Form.Add_Shown({$form.Activate()})
  1289.     $dialogResult = $form.ShowDialog()
  1290.  
  1291.     $Form.CancelButton = $btnCancel
  1292.     $Form.AcceptButton = $btnSend
  1293.     #region FORM SUBMIT
  1294.     if ($dialogResult -eq "Yes") {
  1295.        
  1296.         if ($rbNotificationTypeI.Checked){
  1297.             Set-Variable -name NotificationType -Value "Normal"}
  1298.             elseif ($rbNotificationTypeW.Checked){
  1299.                 Set-Variable -Name NotificationType -Value "High"}
  1300.         if ($cbAffectedServices.Checked -eq $False) {
  1301.             $lblAffectedServices.Text = ""
  1302.             $txtAffectedServices.Text = ""}
  1303.         if ($cbOutage1.Checked -eq $False) {
  1304.             $lblOutage1.Text = ""
  1305.             $txtOutage.Text = ""}
  1306.         if ($cbYou.Checked -eq $False) {
  1307.             $lblYou.Text = ""
  1308.             $txtYou.Text = ""}
  1309.         if ($ddType.Text -eq "Outage") {
  1310.             $txtOutage.Text = ""
  1311.                 if ($rbOutageStartTimePM.Checked -eq $True) {$script:rbOutageStartTimePM = $rbOutageStartTimePM.Text}
  1312.                     elseif ($rbOutageStartTimeAM.Checked -eq $True) {$script:rbOutageStartTimeAM = $rbOutageStartTimeAM.Text}
  1313.                 if ($rbOutageEndTimePM.Checked -eq $True) {$script:rbOutageEndTimePM = $rbOutageEndTimePM.Text}
  1314.                     elseif ($rbOutageEndTimeAM.Checked -eq $True) {$script:rbOutageEndTimeAM = $rbOutageEndTimeAM.Text}
  1315.                 }
  1316.         if ($dialogResult -eq "OK"){Send-Email}
  1317.     }
  1318.    
  1319.     if ($dialogResult -eq "OK") {
  1320.         if ($rbNotificationTypeI.Checked){
  1321.             Set-Variable -name NotificationType -Value "Normal"}
  1322.             elseif ($rbNotificationTypeW.Checked){
  1323.                 Set-Variable -Name NotificationType -Value "High"}
  1324.         if ($cbAffectedServices.Checked -eq $False) {
  1325.             $lblAffectedServices.Text = ""
  1326.             $txtAffectedServices.Text = ""}
  1327.         if ($cbOutage1.Checked -eq $False) {
  1328.             $lblOutage1.Text = ""
  1329.             $txtOutage.Text = ""}
  1330.         if ($cbYou.Checked -eq $False) {
  1331.             $lblYou.Text = ""
  1332.             $txtYou.Text = ""}
  1333.         if ($ddType.Text -eq "Outage") {
  1334.             $txtOutage.Text = ""
  1335.                 if ($rbOutageStartTimePM.Checked -eq $True) {$script:rbOutageStartTimeAMPM = $rbOutageStartTimePM.Text}
  1336.                     elseif ($rbOutageStartTimeAM.Checked -eq $True) {$script:rbOutageStartTimeAMPM = $rbOutageStartTimeAM.Text}
  1337.                 if ($rbOutageEndTimePM.Checked -eq $True) {$script:rbOutageEndTimeAMPM = $rbOutageEndTimePM.Text}
  1338.                     elseif ($rbOutageEndTimeAM.Checked -eq $True) {$script:rbOutageEndTimeAMPM = $rbOutageEndTimeAM.Text}
  1339.                 }
  1340.         if ($dialogResult -eq "OK"){Send-Email}
  1341.     }
  1342.     elseif ($dialogResult -eq "Cancel"){exit}
  1343.     #endregion FORM SUBMIT
  1344.     #endregion FORM
  1345.     clear-variable -name Body
  1346.     clear-variable -name OutageArray
  1347.     clear-variable -name AddressList
  1348.     clear-variable -name OutageArrayAtt
  1349.     clear-variable -name SectionArray
Advertisement
Add Comment
Please, Sign In to add comment