Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- Sends Email Notifications with consistant formatting to selected distribution lists
- .DESCRIPTION
- Ability to change template based on the type of notification being sent with a multitude of customisations
- and options for embedding images and attach documents (docx & pdfs)
- .NOTES
- Version 1.4
- #>
- #region PARAMETERS
- Param(
- [int]$DisplayMode = 4,
- [int]$SelectionCount = 1,
- [datetime]$TodayDate = $(Get-Date),
- [datetime]$DateSelected = $TodayDate,
- $FirstDayofWeek = -1,
- [datetime[]]$Bold = @(),
- [datetime[]]$YBold = @(),
- [datetime[]]$MBold = @(),
- [int]$ScrollBy = $DisplayMode,
- [switch]$WeekNumbers,
- [string]$Title = "Date Picker",
- [switch]$NoTodayCircle,
- [datetime]$MinDate = [datetime]"2017-01-01",
- [datetime]$MaxDate = [datetime]"2018-12-31"
- )
- $script:OutageArray =@()
- $script:AddressList =@()
- $script:OutageArrayAtt =@()
- $script:SectionArray = New-Object object[] 5
- $script:ScriptPath = $PSScriptRoot
- $script:BannerInformation = $PSScriptRoot+"\"+"information.png"
- $script:BannerWarning = $PSScriptRoot+"\"+"warning.png"
- $script:BannerOutage = $PSScriptRoot+"\"+"outage.png"
- #endregion PARAMETERS
- #region DECLARE FUNCTIONS
- #region EMAIL CREATION
- Function Send-Email()
- {
- Param($PeerReview)
- $Email = New-Object system.net.mail.mailmessage
- $Today = Get-Date -Hour 0 -Minute 0 -Second 1 -Millisecond 0
- $script:HTMLName = "EmailNotification.html"
- $script:frmSubject = $txtSubject.Text
- $script:frmDate = $txtDate.Text
- $script:frmAffectedServices = $txtAffectedServices.Text.Replace("`n", "<br>")
- $script:frmOutage = $txtOutage.Text.Replace("`n", "<br>")
- $script:frmYou = $txtYou.Text.Replace("`n", "<br>")
- if ($PeerReview -eq "True") {$script:frmTo = "<username>@<domain>"
- $script:Subject = "[PEER REVIEW] - $frmSubject"
- $btnSend.Visible = $True
- $btnPeerReview.Visible = $False
- $NotificationType = 'High'}
- else {$script:frmTo = $txtEmailTo.Text
- $script:Subject = "[APAC IT] - $frmSubject"}
- $script:frmBCC = $txtBCC.Text
- $script:frmAffectedServicesTitle = $lblAffectedServices.Text
- $script:frmYouTitle = $lblYou.Text
- #region ATTACHMENT TO SECTION
- if ($ddSection1.Text -eq "1") {
- $script:SectionArray[0] = "SERVICESIMG"}
- elseif ($ddSection1.Text -eq "2") {
- $script:SectionArray[0] = "OUTAGEIMG"}
- elseif ($ddSection1.Text -eq "3") {
- $script:SectionArray[0] = "YOUIMG"}
- if ($ddSection2.Text -eq "1") {
- $script:SectionArray[1] = "SERVICESIMG"}
- elseif ($ddSection2.Text -eq "2") {
- $script:SectionArray[1] = "OUTAGEIMG"}
- elseif ($ddSection2.Text -eq "3") {
- $script:SectionArray[1] = "YOUIMG"}
- if ($ddSection3.Text -eq "1") {
- $script:SectionArray[2] = "SERVICESIMG"}
- elseif ($ddSection3.Text -eq "2") {
- $script:SectionArray[2] = "OUTAGEIMG"}
- elseif ($ddSection3.Text -eq "3") {
- $script:SectionArray[2] = "YOUIMG"}
- if ($ddSection4.Text -eq "1") {
- $script:SectionArray[3] = "SERVICESIMG"}
- elseif ($ddSection4.Text -eq "2") {
- $script:SectionArray[3] = "OUTAGEIMG"}
- elseif ($ddSection4.Text -eq "3") {
- $script:SectionArray[3] = "YOUIMG"}
- if ($ddSection5.Text -eq "1") {
- $script:SectionArray[4] = "SERVICESIMG"}
- elseif ($ddSection5.Text -eq "2") {
- $script:SectionArray[4] = "OUTAGEIMG"}
- elseif ($ddSection5.Text -eq "3") {
- $script:SectionArray[4] = "YOUIMG"}
- #endregion ATTACHMENTMENT TO SECTION
- $script:frmOutageStartDateTitle = $lblOutageStartDate.Text
- $script:frmOutageStartTimeTitle = $lblOutageStartTime.Text
- $script:frmOutageEndDateTitle = $lblOutageEndDate.Text
- $script:frmOutageEndTimeTitle = $lblOutageEndTime.Text
- $script:frmOutageStartDate = $txtOutageStartDate.Text
- $script:frmOutageEndDate = $txtOutageEndDate.Text
- $script:frmOutageStartTimeHH = $ddOutageStartTimeHH.Text
- $script:frmOutageStartTimeMM = $ddOutageStartTimeMM.Text
- $script:frmOutageStartTimeAMPM = $script:rbOutageStartTimeAMPM
- $script:frmOutageEndTimeHH = $ddOutageEndTimeHH.Text
- $script:frmOutageEndTimeMM = $ddOutageEndTimeMM.Text
- $script:frmOutageEndTimeAMPM = $script:rbOutageEndTimeAMPM
- $script:frmBanner = $pbBanner.ImageLocation
- If ($ddType.Text -eq "Outage") {$script:frmOutageTitle = $script:outageTitle}
- Else {$script:frmOutageTitle = $lblOutage1.Text}
- $Counter = 1
- $IMGCounter = 1
- $SectionCounter = 0
- #region BODY REPLACE
- $script:Body = Get-Content -Path $($script:ScriptPath+"\"+$script:HTMLName) | Out-String
- If ($PeerReview -eq "True") {$script:Body = $Body.Replace("[DATE]","<b>Emailing: "+ $txtEmailTo.Text + "</b>")}
- Else {$script:Body = $Body.Replace("[DATE]",$frmDate)}
- $script:Body = $Body.Replace("[SERVICES]",$frmAffectedServicesTitle)
- $script:Body = $Body.Replace("<SERVICES>",$frmAffectedServices)
- $script:Body = $Body.Replace("[YOU]",$frmYouTitle)
- $script:Body = $Body.Replace("<YOU>",$frmYou)
- $script:Body = $Body.Replace("<OUTAGE>",$frmOutage)
- If ($ddType.Text -eq "Outage"){
- $script:Body = $Body.Replace("<OutageForm>","<table width=""100%"" border=""0""><tr class=""MsoNormal""><td><b>`
- $frmOutageStartDateTitle</b></td><td>$frmOutageStartDate</td></tr><tr class=""MsoNormal""><td><b>`
- $frmOutageStartTimeTitle</b></td><td>$frmOutageStartTimeHH`:$frmOutageStartTimeMM $frmOutageStartTimeAMPM</td><tr class=""MsoNormal""><td></td><td></td></tr><tr class=""MsoNormal""><td><b>`
- $frmOutageEndDateTitle</b></td><td>$frmOutageEndDate</td><tr class=""MsoNormal""><td><b>`
- $frmOutageEndTimeTitle</b></td><td>$frmOutageEndTimeHH`:$frmOutageEndTimeMM $frmOutageEndTimeAMPM</td></tr></table>")
- if ($rbOutageTypeUN.Checked -eq $True) {$script:Body = $Body.Replace("[OutageTitle]",$rbOutageTypeUN.Tag+" Outage Window")}
- elseif ($rbOutageTypeSC.Checked -eq $True) {$script:Body = $Body.Replace("[OutageTitle]",$rbOutageTypeSC.Tag+" Outage Window")}
- }
- Else {$script:Body = $Body.Replace("[OutageTitle]",$frmOutageTitle)}
- #endregion BODY REPLACE
- #region EMBED IMAGE LOOP
- foreach ($Image in $script:OutageArray){
- $TempImgAttach = new-object Net.Mail.Attachment($Image)
- $TempImgAttach.ContentDisposition.Inline = $True
- $TempImgAttach.ContentDisposition.DispositionType = "Inline"
- if ($TempImgAttach.Name -like "*.png") {$TempImgAttach.ContentType.MediaType = "image/png"}
- elseif ($TempImgAttach.Name -like "*.jpg") {$TempImgAttach.ContentType.MediaType = "image/jpg"}
- elseif ($TempImgAttach.Name -like "*.jpeg") {$TempImgAttach.ContentType.MediaType = "image/jpeg"}
- $TempImgAttach.ContentId = "Attachment" + $Counter
- $TempImgAttach.ContentType.Name = $TempImgAttach.Name
- $Email.Attachments.Add($TempImgAttach)
- $frmSectionVar = $script:SectionArray[$SectionCounter]
- $frmSectionVarFull = $frmSectionVar+$IMGCounter
- $IMGSrc = "<BR><img src=`'cid:$($TempImgAttach.ContentId)`' /><BR><BR>"
- $Body = $Body.Replace("<"+$frmSectionVarFull+">",$IMGSrc)
- #region INCREASE LOOP COUNT
- $IMGCounter++
- $Counter++
- $SectionCounter++
- }
- #endregion INCREASE LOOP COUNT
- #endregion EMBED IMAGE LOOP
- #region BANNER EMBED
- $BannerCounter = 10
- $BannerAtt = new-object Net.Mail.Attachment($script:frmBanner)
- $BannerAtt.ContentDisposition.Inline = $True
- $BannerAtt.ContentDisposition.DispositionType = "Inline"
- $BannerAtt.ContentType.MediaType = "image/png"
- $BannerAtt.ContentId = "Attachment" + $BannerCounter
- $BannerAtt.ContentType.Name = $BannerAtt.Name
- $Email.Attachments.Add($BannerAtt)
- $BannerIMGSrc = "<img src=`'cid:$($BannerAtt.ContentId)`' />"
- $Body = $Body.Replace("<banner>",$BannerIMGSrc)
- #endregion BANNER EMBED
- #region START DOCUMENT ATTACHMENT
- foreach ($Doc in $script:OutageArrayAtt){
- $TempDocAttach = new-object Net.Mail.Attachment($Doc)
- $Email.Attachments.Add($TempDocAttach)
- }
- #endregion START DOCUMENT ATTACHMENT
- #region SEND EMAIL
- $Email.From = "IT <IT@<domain>>"
- $Email.Subject = $script:Subject
- $Email.Body = $Body
- $Email.IsBodyHTML = $True
- $Email.ReplyTo = "IT.Support@<domain>"
- $Email.Priority = $NotificationType
- # $Email.To.Add("<username>@<domain>")
- if ($script:frmBCC) {$Email.BCC.Add("$script:frmBCC")}
- else {# do nothing
- }
- if ($script:frmTo) {$Email.To.Add("$script:frmTo")}
- else {# do nothing
- }
- $SMTPClient = New-Object Net.Mail.SmtpClient("<SMTP ADDRESS>", 25 )
- if ($script:frmBCC -or $script:frmTo) {$SMTPClient.Send($Email)} #wont send email without an address in TO or BCC
- else {# do nothing
- }
- }
- #endregion SEND EMAIL
- #endregion EMAIL CREATION
- #region DATE PICKER
- Function Get-DateOrdinalSuffix([datetime]$Date) {
- switch -regex ($Date.Day.ToString()) {
- '1(1|2|3)$' { 'th'; break }
- '.?1$' { 'st'; break }
- '.?2$' { 'nd'; break }
- '.?3$' { 'rd'; break }
- default { 'th'; break }
- }
- }
- Function Show-BalloonTip
- {
- #[CmdletBinding(SupportsShouldProcess = $True)]
- Param
- (
- [Parameter(Mandatory=$True)]
- $Text,
- [Parameter(Mandatory=$True)]
- $Title,
- [ValidateSet('None', 'Info', 'Warning', 'Error')]
- $Icon = 'Info',
- $Timeout = 10000
- )
- if ($script:balloon -eq $null)
- {
- $script:balloon = New-Object System.Windows.Forms.NotifyIcon
- }
- $path = Get-Process -id $pid | Select-Object -ExpandProperty Path
- $balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
- $balloon.BalloonTipIcon = $Icon
- $balloon.BalloonTipText = $Text
- $balloon.BalloonTipTitle = $Title
- $balloon.Visible = $True
- $balloon.ShowBalloonTip($Timeout)
- }
- Function Get-SuffixAndClipboard {
- if(!$Escaped){
- for(
- $day = $cal.SelectionRange.Start;
- $day -le $cal.SelectionRange.End;
- $day = $day.AddDays(1)
- )
- {
- $suffix = Get-DateOrdinalSuffix $day
- $DateFormatted = "{0} the {2}{3} of {1:MMMM} {4}" -f $day.DayOfWeek, $day, $day.Day, $suffix, $day.Year
- $DateFormatted | clip.exe
- Show-BalloonTip -Text "$DateFormatted has been added to your clipboard" -Title "Clipboard Updated" -icon Info
- }
- }
- }
- #endregion DATE PICKER
- #region GET DATE ORDINAL
- Function Get-DateOrdinalSuffix1
- {
- $txtDateToday = (Get-Date)
- $suffix1 = Get-DateOrdinalSuffix $txtDateToday
- $DateFormattedTxtBox ="{0} the {1}{2} of {3:MMMM} {4}" -f $txtDateToday.DayOfWeek, $txtDateToday.Day, $suffix1, $txtDateToday, $txtDateToday.Year
- $DateFormattedTxtBox
- }
- #endregion GET DATE ORDINAL
- #region DOCUMENT PICKER
- Function Get-FileNameDoc ($initialDirectory)
- {
- [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
- $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
- $OpenFileDialog.Multiselect = $True
- $OpenFileDialog.Title = "Choose a Document"
- $OpenFileDialog.InitialDirectory = $initialDirectory
- $OpenFileDialog.Filter = 'Document (*.docx, *.pdf)|*.docx;*.pdf'
- $OpenFileDialog.ShowDialog() | Out-Null
- $OpenFileDialog.FileNames | ForEach-Object {[Void]$txtOutageAtt.Items.Add($_)}
- ForEach ($Item in $txtOutageAtt.Items)
- {$script:OutageArrayAtt += $Item}
- }
- #endregion DOCUMENT PICKER
- #region IMAGE PICKER
- Function Get-FileName ($initialDirectory)
- {
- [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
- $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
- $OpenFileDialog.Multiselect = $True
- $OpenFileDialog.Title = "Choose an image"
- $OpenFileDialog.InitialDirectory = $initialDirectory
- $OpenFileDialog.Filter = 'Images (*.jpg, *.png)|*.jpg;*.png'
- $OpenFileDialog.ShowDialog() | Out-Null
- $OpenFileDialog.FileNames | ForEach-Object {[Void]$txtOutageIMG1.Items.Add($_)}
- ForEach ($Item in $txtOutageIMG1.Items)
- {$script:OutageArray += $Item}
- }
- #endregion IMAGE PICKER
- #region ADDRESS PICKER FORM & FUNCTION
- Function Get-Addresses () {
- $Script:AddressListArray =@()
- $AddressForm = New-Object system.Windows.Forms.Form
- $AddressForm.Text = "Address Picker"
- $AddressForm.TopMost = $True
- $AddressForm.Width = 430
- $AddressForm.Height = 740
- $AddressForm.KeyPreview = $True
- $AddressForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {
- # If {Enter} Do {Nothing}
- }
- })
- $AddressForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {
- $AddressForm.Close()
- }
- })
- $lbAddressList = New-Object System.Windows.Forms.ListBox
- $lbAddressList.Name = "Address List"
- $Script:AddressList = $Script:AddressListArray =@()
- $Script:AddressList = $lbAddressList.Items
- ForEach ($Item in $Script:AddressList)
- {$Script:AddressList += $Item}
- $handler_button1_Click={
- $lbAddressList.Items.Clear();
- if ($EmailAddress01.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress02.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress03.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress04.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress05.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress06.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress07.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress08.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress09.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress10.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress11.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress12.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress13.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- if ($EmailAddress14.Checked) {$lbAddressList.Items.Add("@<<domain>>")}
- 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....")}
- }
- #region EMAIL ADDRESS LIST
- $EmailAddress01 = new-object System.Windows.Forms.checkbox
- $EmailAddress01.Location = new-object System.Drawing.Size(30,20)
- $EmailAddress01.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress01.Text = "<@<domain>>"
- $EmailAddress01.Checked = $False
- $EmailAddress01.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress01)
- $EmailAddress02 = new-object System.Windows.Forms.checkbox
- $EmailAddress02.Location = new-object System.Drawing.Size(30,60)
- $EmailAddress02.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress02.Text = "<@<domain>"
- $EmailAddress02.Checked = $False
- $EmailAddress02.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress02)
- $EmailAddress03 = new-object System.Windows.Forms.checkbox
- $EmailAddress03.Location = new-object System.Drawing.Size(30,100)
- $EmailAddress03.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress03.Text = "@<domain>>"
- $EmailAddress03.Checked = $False
- $EmailAddress03.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress03)
- $EmailAddress04 = new-object System.Windows.Forms.checkbox
- $EmailAddress04.Location = new-object System.Drawing.Size(30,140)
- $EmailAddress04.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress04.Text = "<@<domain>>"
- $EmailAddress04.Checked = $False
- $EmailAddress04.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress04)
- $EmailAddress05 = new-object System.Windows.Forms.checkbox
- $EmailAddress05.Location = new-object System.Drawing.Size(30,180)
- $EmailAddress05.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress05.Text = "<@<domain>>"
- $EmailAddress05.Checked = $False
- $EmailAddress05.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress05)
- $EmailAddress06 = new-object System.Windows.Forms.checkbox
- $EmailAddress06.Location = new-object System.Drawing.Size(30,220)
- $EmailAddress06.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress06.Text = "@<domain>>"
- $EmailAddress06.Checked = $False
- $EmailAddress06.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress06)
- $EmailAddress07 = new-object System.Windows.Forms.checkbox
- $EmailAddress07.Location = new-object System.Drawing.Size(30,260)
- $EmailAddress07.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress07.Text = "@<domain>>"
- $EmailAddress07.Checked = $False
- $EmailAddress07.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress07)
- $EmailAddress08 = new-object System.Windows.Forms.checkbox
- $EmailAddress08.Location = new-object System.Drawing.Size(30,300)
- $EmailAddress08.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress08.Text = "@<domain>>"
- $EmailAddress08.Checked = $False
- $EmailAddress08.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress08)
- $EmailAddress09 = new-object System.Windows.Forms.checkbox
- $EmailAddress09.Location = new-object System.Drawing.Size(30,340)
- $EmailAddress09.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress09.Text = "@<domain>>"
- $EmailAddress09.Checked = $False
- $EmailAddress09.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress09)
- $EmailAddress10 = new-object System.Windows.Forms.checkbox
- $EmailAddress10.Location = new-object System.Drawing.Size(30,380)
- $EmailAddress10.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress10.Text = "@<domain>>"
- $EmailAddress10.Checked = $False
- $EmailAddress10.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress10)
- $EmailAddress11 = new-object System.Windows.Forms.checkbox
- $EmailAddress11.Location = new-object System.Drawing.Size(30,420)
- $EmailAddress11.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress11.Text = "@<domain>>"
- $EmailAddress11.Checked = $False
- $EmailAddress11.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress11)
- $EmailAddress12 = new-object System.Windows.Forms.checkbox
- $EmailAddress12.Location = new-object System.Drawing.Size(30,460)
- $EmailAddress12.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress12.Text = "@<domain>>"
- $EmailAddress12.Checked = $False
- $EmailAddress12.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress12)
- $EmailAddress13 = new-object System.Windows.Forms.checkbox
- $EmailAddress13.Location = new-object System.Drawing.Size(30,500)
- $EmailAddress13.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress13.Text = "@<domain>>"
- $EmailAddress13.Checked = $False
- $EmailAddress13.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress13)
- $EmailAddress14 = new-object System.Windows.Forms.checkbox
- $EmailAddress14.Location = new-object System.Drawing.Size(30,540)
- $EmailAddress14.Size = new-object System.Drawing.Size(520,50)
- $EmailAddress14.Text = "@<domain>>"
- $EmailAddress14.Checked = $False
- $EmailAddress14.add_click($handler_button1_Click)
- $AddressForm.Controls.Add($EmailAddress14)
- #endregion EMAIL ADDRESS LIST
- $btnTo = New-Object system.windows.Forms.Button
- $btnTo.Text = "Populate To Field "
- $btnTo.Width = 160
- $btnTo.Height = 30
- $btnTo.location = new-object system.drawing.point(30,600)
- $btnTo.Font = "Microsoft Sans Serif,10"
- $btnTo.Add_Click({$txtEmailTo.Text = $Script:AddressList -Join '; ';$AddressForm.Close()})
- $btnTo.DialogResult=[System.Windows.Forms.DialogResult]::OK
- $AddressForm.controls.Add($btnTo)
- $btnBCC = New-Object system.windows.Forms.Button
- $btnBCC.Text = "Populate BCC Field"
- $btnBCC.Width = 160
- $btnBCC.Height = 30
- $btnBCC.location = new-object system.drawing.point(190,600)
- $btnBCC.Add_Click({$txtBCC.Text = $Script:AddressList -Join '; ';$AddressForm.Close()})
- $btnBCC.Font = "Microsoft Sans Serif,10"
- $btnBCC.DialogResult=[System.Windows.Forms.DialogResult]::OK
- $AddressForm.controls.Add($btnBCC)
- $btnCancel = New-Object system.windows.Forms.Button
- $btnCancel.Text = "Cancel"
- $btnCancel.Width = 320
- $btnCancel.Height = 30
- $btnCancel.location = new-object system.drawing.point(30,640)
- $btnCancel.Font = "Microsoft Sans Serif,10"
- $btnCancel.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
- $AddressForm.controls.Add($btnCancel)
- $AddressForm.Add_Shown({$Addressform.Activate()})
- $dialogResult = $Addressform.ShowDialog()
- }
- #endregion ADDRESS PICKER FORM & FUNCTION
- #endregion DECLARE FUNCTIONS
- #region SWITCHES
- #region PRIORITY SET
- $radioButtons_CheckedChanged={
- if ($rbNotificationTypeI.Checked -eq $True) {$lblPrioritySet.Text = $rbNotificationTypeI.Tag
- $lblPrioritySet.BackColor = ""}
- elseif ($rbNotificationTypeW.Checked -eq $True) {$lblPrioritySet.Text = $rbNotificationTypeW.Tag
- $lblPrioritySet.BackColor = "Red"}
- }
- #endregion PRIORITY SET
- #region OUTAGE TYPE
- $radioButtons_CheckedChangedOutageType={
- if ($rbOutageTypeUN.Checked -eq $True) {$txtSubject.Text = $rbOutageTypeUN.Tag + " Outage"
- $script:outageTitle = $rbOutageTypeUN.Tag + " Outage"
- $rbGroupBoxOutage.BackColor = ""}
- elseif ($rbOutageTypeSC.Checked -eq $True) {$txtSubject.Text = $rbOutageTypeSC.Tag + " Outage"
- $script:outageTitle = $rbOutageTypeSC.Tag + " Outage"
- $rbGroupBoxOutage.BackColor = ""}
- }
- #endregion OUTAGE TYPE
- #region NOTIFICATION TYPE
- $DropDown_CheckedChanged={
- if ($ddType.Text -eq "Informational") {
- $lblAffectedServices.Text = "Information"
- $lblOutage1.Text = "Additional Information"
- $lblYou.Text = "What You Should Do"
- $lblAffectedServices.ReadOnly = $True
- $lblOutage1.ReadOnly = $True
- $lblYou.ReadOnly = $True
- $rbOutageTypeSC.Checked = $False
- $txtSubject.Text = ""
- $ddBanner.SelectedIndex = 0
- $ddBanner.Enabled = $False
- $pbBanner.ImageLocation = $script:BannerInformation
- $pbBanner.Image = [System.Drawing.Image]::Fromfile($script:BannerInformation)
- $txtOutage.Visible = $True
- $ddBanner.Visible = $False
- ForEach ($Control in $Form.Controls) {If ($Control.Tag -eq '1') {$control.visible = $False}}
- }
- elseif ($ddType.Text -eq "Warning") {
- $lblAffectedServices.Text = "Warning"
- $lblOutage1.Text = "Information"
- $lblYou.Text = "What You Should Do"
- $lblAffectedServices.ReadOnly = $True
- $lblOutage1.ReadOnly = $True
- $lblYou.ReadOnly = $True
- $rbOutageTypeSC.Checked = $False
- $txtSubject.Text = ""
- $ddBanner.SelectedIndex = 1
- $ddBanner.Enabled = $False
- $pbBanner.ImageLocation = $script:BannerWarning
- $pbBanner.Image = [System.Drawing.Image]::Fromfile($script:BannerWarning)
- $txtOutage.Visible = $True
- $ddBanner.Visible = $False
- ForEach ($Control in $Form.Controls) {If ($Control.Tag -eq '1') {$control.visible = $False}}
- }
- elseif ($ddType.Text -eq "Outage") {
- $lblAffectedServices.Text = "Information"
- $lblOutage1.Text = "Outage Window"
- $lblYou.Text = "What You Should Do"
- $lblAffectedServices.ReadOnly = $True
- $lblOutage1.ReadOnly = $True
- $lblYou.ReadOnly = $True
- $ddBanner.Enabled = $False
- $ddBanner.SelectedIndex = 2
- $pbBanner.ImageLocation = $script:BannerOutage
- $pbBanner.Image = [System.Drawing.Image]::Fromfile($script:BannerOutage)
- $txtOutage.Visible = $False
- $ddBanner.Visible = $False
- ForEach ($Control in $Form.Controls) {If ($Control.Tag -eq '1') {$control.visible = $True}}
- }
- elseif ($ddType.Text -eq "Custom") {
- $lblAffectedServices.ReadOnly = $False
- $lblOutage1.ReadOnly = $False
- $lblYou.ReadOnly = $False
- $rbOutageTypeSC.Checked = $False
- $ddBanner.Enabled = $True
- $ddBanner.SelectedIndex = 0
- $txtSubject.Text = ""
- $txtOutage.Visible = $True
- $ddBanner.Visible = $True
- ForEach ($Control in $Form.Controls) {If ($Control.Tag -eq '1') {$control.visible = $False}}
- }
- }
- #endregion NOTIFICATION TYPE
- #region BANNER PICKER
- $BannerDropDown_CheckedChanged={
- if ($ddBanner.Text -eq "Informational") {
- $pbBanner.ImageLocation = "$script:BannerInformation"
- $pbBanner.Image = [System.Drawing.Image]::Fromfile("$script:BannerInformation")}
- elseif ($ddBanner.Text -eq "Warning") {
- $pbBanner.ImageLocation = "$script:BannerWarning"
- $pbBanner.Image = [System.Drawing.Image]::Fromfile("$script:BannerWarning")}
- elseif ($ddBanner.Text -eq "Outage") {
- $pbBanner.ImageLocation = "$script:BannerOutage"
- $pbBanner.Image = [System.Drawing.Image]::Fromfile("$script:BannerOutage")
- }
- }
- #endregion BANNER PICKER
- #region HIDE SECTIONS
- $handler_button2_Click= {
- if ($cbAffectedServices.Checked -eq $False) {$lblAffectedServices.Visible = $False
- $txtAffectedServices.Visible = $False}
- else {$lblAffectedServices.Visible = $True
- $txtAffectedServices.Visible = $True}
- }
- $handler_button3_Click= {
- if ($cbOutage1.Checked -eq $False) {$lblOutage1.Visible = $False
- $txtOutage.Visible = $False}
- else {$lblOutage1.Visible = $True
- $txtOutage.Visible = $True}
- }
- $handler_button4_Click= {
- if ($cbYou.Checked -eq $False) {$lblYou.Visible = $False
- $txtYou.Visible = $False}
- else {$lblYou.Visible = $True
- $txtYou.Visible = $True}
- }
- #endregion HIDE SECTIONS
- #region FORM
- Add-Type -AssemblyName System.Windows.Forms
- $Form = New-Object system.Windows.Forms.Form
- $Form.Text = "Form"
- $Form.TopMost = $True
- $Form.Width = 1000
- $Form.Height = 1000
- # $Form.BackColor = [System.Drawing.ColorTranslator]::FromHtml('#'+"3f3f3f")
- $Form.KeyPreview = $True
- $Form.Add_KeyDown({if ($_.KeyCode -eq "Enter")
- {
- # If {Enter} Do {Nothing}
- }
- })
- $Form.Add_KeyDown({if ($_.KeyCode -eq "Escape")
- {
- $Form.Close()
- }
- })
- $ddType = new-object System.Windows.Forms.ComboBox
- $ddType.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddType.Location = new-object System.Drawing.Size(10,10)
- $ddType.Size = new-object System.Drawing.Size(130,30)
- $ddType.Items.Add("Informational") | Out-Null
- $ddType.Items.Add("Warning") | Out-Null
- $ddType.Items.Add("Outage") | Out-Null
- $ddType.Items.Add("Custom") | Out-Null
- $ddType.SelectedIndex=0
- $ddType.add_SelectedIndexChanged($DropDown_CheckedChanged)
- $form.Controls.Add($ddType)
- $lblEmailTo = New-Object system.windows.Forms.Label
- $lblEmailTo.Text = "To"
- $lblEmailTo.AutoSize = $True
- $lblEmailTo.Width = 25
- $lblEmailTo.Height = 10
- $lblEmailTo.location = new-object system.drawing.point(10,40)
- $lblEmailTo.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblEmailTo)
- $lblSubject = New-Object system.windows.Forms.Label
- $lblSubject.Text = "Subject"
- $lblSubject.AutoSize = $True
- $lblSubject.Width = 25
- $lblSubject.Height = 10
- $lblSubject.location = new-object system.drawing.point(10,80)
- $lblSubject.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblSubject)
- $lblBCC = New-Object system.windows.Forms.Label
- $lblBCC.Text = "BCC"
- $lblBCC.AutoSize = $True
- $lblBCC.Width = 25
- $lblBCC.Height = 10
- $lblBCC.location = new-object system.drawing.point(550,40)
- $lblBCC.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblBCC)
- $lblPriority = New-Object system.windows.Forms.Label
- $lblPriority.Text = "Priority"
- $lblPriority.AutoSize = $True
- $lblPriority.Width = 25
- $lblPriority.Height = 10
- $lblPriority.location = new-object system.drawing.point(10,120)
- $lblPriority.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblPriority)
- $lblPrioritySet = New-Object system.windows.Forms.Label
- $lblPrioritySet.Text = "Normal"
- $lblPrioritySet.AutoSize = $True
- $lblPrioritySet.Width = 25
- $lblPrioritySet.Height = 10
- $lblPrioritySet.location = new-object system.drawing.point(200,120)
- $lblPrioritySet.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblPrioritySet)
- $lblDate = New-Object system.windows.Forms.Label
- $lblDate.Text = "Date"
- $lblDate.AutoSize = $True
- $lblDate.Width = 25
- $lblDate.Height = 10
- $lblDate.location = new-object system.drawing.point(550,80)
- $lblDate.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblDate)
- $cbAffectedServices = New-Object System.Windows.Forms.CheckBox
- $cbAffectedServices.Location = New-Object System.Drawing.Point(10,160)
- $cbAffectedServices.Height = 25
- $cbAffectedServices.Width = 20
- $cbAffectedServices.Checked = $True
- $cbAffectedServices.add_click($handler_button2_Click)
- $Form.controls.Add($cbAffectedServices)
- $lblAffectedServices = New-Object system.windows.Forms.RichTextBox
- $lblAffectedServices.Text = "Information"
- $lblAffectedServices.ReadOnly = $True
- $lblAffectedServices.AutoSize = $True
- $lblAffectedServices.Multiline = $False
- $lblAffectedServices.Width = 155
- $lblAffectedServices.Height = 22
- $lblAffectedServices.location = new-object system.drawing.point(30,160)
- $lblAffectedServices.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblAffectedServices)
- $cbOutage1 = New-Object System.Windows.Forms.CheckBox
- $cbOutage1.Location = New-Object System.Drawing.Point(10,380)
- $cbOutage1.Height = 25
- $cbOutage1.Width = 20
- $cbOutage1.Checked = $True
- $cbOutage1.add_click($handler_button3_Click)
- $Form.controls.Add($cbOutage1)
- $lblOutage1 = New-Object system.windows.Forms.RichTextBox
- $lblOutage1.Text = "Additional Information"
- $lblOutage1.ReadOnly = $True
- $lblOutage1.AutoSize = $True
- $lblOutage1.Multiline = $False
- $lblOutage1.Width = 155
- $lblOutage1.Height = 22
- $lblOutage1.location = new-object system.drawing.point(30,380)
- $lblOutage1.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblOutage1)
- $lblOutageType = New-Object System.Windows.Forms.RadioButton
- $lblOutageType.Text = "Additional Information"
- $lblOutageType.AutoSize = $True
- $lblOutageType.Width = 175
- $lblOutageType.Height = 10
- $lblOutageType.location = new-object system.drawing.point(10,380)
- $lblOutageType.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblOutage1)
- $rbOutageTypeUN = New-Object system.windows.Forms.RadioButton
- $rbOutageTypeUN.Text = "Unscheduled"
- $rbOutageTypeUN.Tag = 'Unscheduled'
- $rbOutageTypeUN.AutoSize = $True
- $rbOutageTypeUN.Width = 100
- $rbOutageTypeUN.Height = 22
- $rbOutageTypeUN.location = new-object system.drawing.point(10,10)
- $rbOutageTypeUN.Font = "Microsoft Sans Serif,10"
- $rbOutageTypeUN.add_click($radioButtons_CheckedChangedOutageType)
- $rbOutageTypeSC = New-Object system.windows.Forms.RadioButton
- $rbOutageTypeSC.Text = "Scheduled"
- $rbOutageTypeSC.Tag = 'Scheduled'
- $rbOutageTypeSC.AutoSize = $True
- $rbOutageTypeSC.Width = 100
- $rbOutageTypeSC.Height = 22
- $rbOutageTypeSC.location = new-object system.drawing.point(200,10)
- $rbOutageTypeSC.Font = "Microsoft Sans Serif,10"
- $rbOutageTypeSC.add_click($radioButtons_CheckedChangedOutageType)
- $rbGroupBoxOutage = New-Object Windows.Forms.Panel
- $rbGroupBoxOutage.Text = ""
- $rbGroupBoxOutage.Visible = $False
- $rbGroupBoxOutage.BackColor = "Red"
- $rbGroupBoxOutage.Left = 200
- $rbGroupBoxOutage.Top = 369
- $rbGroupBoxOutage.Width = 300
- $rbGroupBoxOutage.Height = 40
- $rbGroupBoxOutage.Controls.Add($rbOutageTypeUN)
- $rbGroupBoxOutage.Controls.Add($rbOutageTypeSC)
- $rbGroupBoxOutage.Tag = '1'
- $form.controls.add($rbGroupboxOutage)
- $lblOutageStartDate = New-Object system.windows.Forms.Label
- $lblOutageStartDate.Text = "Start Date"
- $lblOutageStartDate.Visible = $False
- $lblOutageStartDate.AutoSize = $True
- $lblOutageStartDate.Width = 175
- $lblOutageStartDate.Height = 10
- $lblOutageStartDate.location = new-object system.drawing.point(10,420)
- $lblOutageStartDate.Font = "Microsoft Sans Serif,10"
- $lblOutageStartDate.Tag = '1'
- $Form.controls.Add($lblOutageStartDate)
- $lblOutageStartTime = New-Object system.windows.Forms.Label
- $lblOutageStartTime.Text = "Start Time"
- $lblOutageStartTime.Visible = $False
- $lblOutageStartTime.AutoSize = $True
- $lblOutageStartTime.Width = 175
- $lblOutageStartTime.Height = 10
- $lblOutageStartTime.location = new-object system.drawing.point(10,460)
- $lblOutageStartTime.Font = "Microsoft Sans Serif,10"
- $lblOutageStartTime.Tag = '1'
- $Form.controls.Add($lblOutageStartTime)
- $lblOutageEndDate = New-Object system.windows.Forms.Label
- $lblOutageEndDate.Text = "End Date"
- $lblOutageEndDate.Visible = $False
- $lblOutageEndDate.AutoSize = $True
- $lblOutageEndDate.Width = 175
- $lblOutageEndDate.Height = 10
- $lblOutageEndDate.location = new-object system.drawing.point(10,500)
- $lblOutageEndDate.Font = "Microsoft Sans Serif,10"
- $lblOutageEndDate.Tag = '1'
- $Form.controls.Add($lblOutageEndDate)
- $lblOutageEndTime = New-Object system.windows.Forms.Label
- $lblOutageEndTime.Text = "End Time"
- $lblOutageEndTime.Visible = $False
- $lblOutageEndTime.AutoSize = $True
- $lblOutageEndTime.Width = 175
- $lblOutageEndTime.Height = 10
- $lblOutageEndTime.location = new-object system.drawing.point(10,540)
- $lblOutageEndTime.Font = "Microsoft Sans Serif,10"
- $lblOutageEndTime.Tag = '1'
- $Form.controls.Add($lblOutageEndTime)
- $cbYou = New-Object System.Windows.Forms.CheckBox
- $cbYou.Location = New-Object System.Drawing.Point(10,600)
- $cbYou.Height = 25
- $cbYou.Width = 20
- $cbYou.Checked = $True
- $cbYou.add_click($handler_button4_Click)
- $Form.controls.Add($cbYou)
- $lblYou = New-Object system.windows.Forms.RichTextBox
- $lblYou.Text = "What You Should Do"
- $lblYou.ReadOnly = $True
- $lblYou.AutoSize = $True
- $lblYou.Multiline = $False
- $lblYou.Width = 155
- $lblYou.Height = 22
- $lblYou.location = new-object system.drawing.point(30,600)
- $lblYou.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblYou)
- $lblBanner = New-Object System.Windows.Forms.Label
- $lblBanner.Text = "Email Body Banner"
- $lblBanner.AutoSize = $True
- $lblBanner.Width = 175
- $lblBanner.Height = 10
- $lblBanner.location = new-object system.drawing.point(10,720)
- $lblBanner.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($lblBanner)
- $ddBanner = New-Object System.Windows.Forms.ComboBox
- $ddBanner.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddBanner.Location = new-object System.Drawing.Size(10,740)
- $ddBanner.Size = new-object System.Drawing.Size(130,30)
- $ddBanner.Enabled = $False
- $ddBanner.Items.Add("Informational") | Out-Null
- $ddBanner.Items.Add("Warning") | Out-Null
- $ddBanner.Items.Add("Outage") | Out-Null
- $ddBanner.SelectedIndex=0
- $ddBanner.Visible = $False
- $ddBanner.add_SelectedIndexChanged($BannerDropDown_CheckedChanged)
- $form.Controls.Add($ddBanner)
- $txtEmailTo = New-Object system.windows.Forms.RichTextBox
- $txtEmailTo.Multiline = $False
- $txtEmailTo.Width = 300
- $txtEmailTo.Height = 22
- $txtEmailTo.location = new-object system.drawing.point(200,40)
- $txtEmailTo.Font = "Microsoft Sans Serif,10"
- $txtEmailTo.Text = ""
- $Form.controls.Add($txtEmailTo)
- $txtSubject = New-Object system.windows.Forms.RichTextBox
- $txtSubject.Multiline = $False
- $txtSubject.Width = 300
- $txtSubject.Height = 22
- $txtSubject.location = new-object system.drawing.point(200,80)
- $txtSubject.Font = "Microsoft Sans Serif,10"
- $txtSubject.Text = "Test"
- $Form.controls.Add($txtSubject)
- $txtBCC = New-Object system.windows.Forms.RichTextBox
- $txtBCC.Multiline = $False
- $txtBCC.Width = 200
- $txtBCC.Height = 22
- $txtBCC.location = new-object system.drawing.point(590,40)
- $txtBCC.Font = "Microsoft Sans Serif,10"
- $txtBCC.Text = ""
- $Form.controls.Add($txtBCC)
- $txtDate = New-Object system.windows.Forms.RichTextBox
- $txtDate.Multiline = $False
- $txtDate.Width = 200
- $txtDate.Height = 22
- $txtDate.location = new-object system.drawing.point(590,80)
- $txtDate.Font = "Microsoft Sans Serif,10"
- $txtDate.Text = Get-DateOrdinalSuffix1 ($DateFormattedTxtBox)
- $Form.controls.Add($txtDate)
- $txtAffectedServices = New-Object System.Windows.Forms.RichTextBox
- $txtAffectedServices.Text = 'Test1'
- $txtAffectedServices.Width = 300
- $txtAffectedServices.Height = 200
- $txtAffectedServices.Multiline = $True
- $txtAffectedServices.location = new-object system.drawing.point(200,160)
- $txtAffectedServices.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($txtAffectedServices)
- $txtOutage = New-Object system.windows.Forms.RichTextBox
- $txtOutage.Width = 300
- $txtOutage.Height = 200
- $txtOutage.Visible = $True
- $txtOutage.Multiline = $True
- $txtOutage.location = new-object system.drawing.point(200,380)
- $txtOutage.Font = "Microsoft Sans Serif,10"
- $txtOutage.Text = 'Test'
- $Form.controls.Add($txtOutage)
- $txtOutageStartDate = New-Object system.windows.Forms.RichTextBox
- $txtOutageStartDate.Width = 300
- $txtOutageStartDate.Height = 22
- $txtOutageStartDate.Visible = $False
- $txtOutageStartDate.Multiline = $False
- $txtOutageStartDate.location = new-object system.drawing.point(200,420)
- $txtOutageStartDate.Font = "Microsoft Sans Serif,10"
- $txtOutageStartDate.Text = 'Double click date on Calendar'
- $txtOutageStartDate.Tag = '1'
- $Form.controls.Add($txtOutageStartDate)
- $ddOutageStartTimeHH = New-Object system.windows.Forms.ComboBox
- $ddOutageStartTimeHH.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddOutageStartTimeHH.Width = 40
- $ddOutageStartTimeHH.Height = 22
- $ddOutageStartTimeHH.Items.Add("01") | Out-Null
- $ddOutageStartTimeHH.Items.Add("02") | Out-Null
- $ddOutageStartTimeHH.Items.Add("03") | Out-Null
- $ddOutageStartTimeHH.Items.Add("04") | Out-Null
- $ddOutageStartTimeHH.Items.Add("05") | Out-Null
- $ddOutageStartTimeHH.Items.Add("06") | Out-Null
- $ddOutageStartTimeHH.Items.Add("07") | Out-Null
- $ddOutageStartTimeHH.Items.Add("08") | Out-Null
- $ddOutageStartTimeHH.Items.Add("09") | Out-Null
- $ddOutageStartTimeHH.Items.Add("10") | Out-Null
- $ddOutageStartTimeHH.Items.Add("11") | Out-Null
- $ddOutageStartTimeHH.Items.Add("12") | Out-Null
- $ddOutageStartTimeHH.Visible = $False
- $ddOutageStartTimeHH.DropDownHeight = 200
- $ddOutageStartTimeHH.location = new-object system.drawing.point(200,460)
- $ddOutageStartTimeHH.Font = "Microsoft Sans Serif,10"
- $ddOutageStartTimeHH.Tag = '1'
- $Form.controls.Add($ddOutageStartTimeHH)
- $ddOutageStartTimeMM = New-Object system.windows.Forms.ComboBox
- $ddOutageStartTimeMM.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddOutageStartTimeMM.Width = 40
- $ddOutageStartTimeMM.Height = 22
- $ddOutageStartTimeMM.Items.Add("00") | Out-Null
- $ddOutageStartTimeMM.Items.Add("15") | Out-Null
- $ddOutageStartTimeMM.Items.Add("30") | Out-Null
- $ddOutageStartTimeMM.Items.Add("45") | Out-Null
- $ddOutageStartTimeMM.Visible = $False
- $ddOutageStartTimeMM.DropDownHeight = 200
- $ddOutageStartTimeMM.AutoSize = $True
- $ddOutageStartTimeMM.location = new-object system.drawing.point(240,460)
- $ddOutageStartTimeMM.Font = "Microsoft Sans Serif,10"
- $ddOutageStartTimeMM.Tag = '1'
- $Form.controls.Add($ddOutageStartTimeMM)
- $rbOutageStartTimeAM = New-Object system.windows.Forms.RadioButton
- $rbOutageStartTimeAM.Text = "AM"
- $rbOutageStartTimeAM.AutoSize = $True
- $rbOutageStartTimeAM.Width = 15
- $rbOutageStartTimeAM.Height = 22
- $rbOutageStartTimeAM.location = new-object system.drawing.point(10,10)
- $rbOutageStartTimeAM.Font = "Microsoft Sans Serif,10"
- # $rbOutageStartTimeAM.add_click($radioButtons_CheckedChangedStartAMPM)
- $rbOutageStartTimePM = New-Object system.windows.Forms.RadioButton
- $rbOutageStartTimePM.Text = "PM"
- $rbOutageStartTimePM.AutoSize = $True
- $rbOutageStartTimePM.Checked = $True
- $rbOutageStartTimePM.Width = 15
- $rbOutageStartTimePM.Height = 22
- $rbOutageStartTimePM.location = new-object system.drawing.point(55,10)
- $rbOutageStartTimePM.Font = "Microsoft Sans Serif,10"
- # $rbOutageStartTimePM.add_click($radioButtons_CheckedChangedStartAMPM)
- $rbGroupBoxStartAMPM = New-Object Windows.Forms.Panel
- $rbGroupBoxStartAMPM.Text = ""
- $rbGroupBoxStartAMPM.Visible = $False
- $rbGroupBoxStartAMPM.Left = 280
- $rbGroupBoxStartAMPM.Top = 452
- $rbGroupBoxStartAMPM.Width = 100
- $rbGroupBoxStartAMPM.Height = 30
- $rbGroupBoxStartAMPM.Controls.Add($rbOutageStartTimeAM)
- $rbGroupBoxStartAMPM.Controls.Add($rbOutageStartTimePM)
- $rbGroupBoxStartAMPM.Tag = '1'
- $form.controls.add($rbGroupBoxStartAMPM)
- $txtOutageEndDate = New-Object system.windows.Forms.RichTextBox
- $txtOutageEndDate.Width = 300
- $txtOutageEndDate.Height = 22
- $txtOutageEndDate.Visible = $False
- $txtOutageEndDate.Multiline = $False
- $txtOutageEndDate.location = new-object system.drawing.point(200,500)
- $txtOutageEndDate.Font = "Microsoft Sans Serif,10"
- $txtOutageEndDate.Text = 'Double click date on Calendar'
- $txtOutageEndDate.Tag = '1'
- $Form.controls.Add($txtOutageEndDate)
- $ddOutageEndTimeHH = New-Object system.windows.Forms.ComboBox
- $ddOutageEndTimeHH.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddOutageEndTimeHH.Width = 40
- $ddOutageEndTimeHH.Height = 22
- $ddOutageEndTimeHH.Items.Add("01") | Out-Null
- $ddOutageEndTimeHH.Items.Add("02") | Out-Null
- $ddOutageEndTimeHH.Items.Add("03") | Out-Null
- $ddOutageEndTimeHH.Items.Add("04") | Out-Null
- $ddOutageEndTimeHH.Items.Add("05") | Out-Null
- $ddOutageEndTimeHH.Items.Add("06") | Out-Null
- $ddOutageEndTimeHH.Items.Add("07") | Out-Null
- $ddOutageEndTimeHH.Items.Add("08") | Out-Null
- $ddOutageEndTimeHH.Items.Add("09") | Out-Null
- $ddOutageEndTimeHH.Items.Add("10") | Out-Null
- $ddOutageEndTimeHH.Items.Add("11") | Out-Null
- $ddOutageEndTimeHH.Items.Add("12") | Out-Null
- $ddOutageEndTimeHH.Visible = $False
- $ddOutageEndTimeHH.DropDownHeight = 200
- $ddOutageEndTimeHH.AutoSize = $True
- $ddOutageEndTimeHH.location = new-object system.drawing.point(200,540)
- $ddOutageEndTimeHH.Font = "Microsoft Sans Serif,10"
- $ddOutageEndTimeHH.Tag = '1'
- $Form.controls.Add($ddOutageEndTimeHH)
- $ddOutageEndTimeMM = New-Object system.windows.Forms.ComboBox
- $ddOutageEndTimeMM.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddOutageEndTimeMM.Width = 40
- $ddOutageEndTimeMM.Height = 22
- $ddOutageEndTimeMM.Items.Add("00") | Out-Null
- $ddOutageEndTimeMM.Items.Add("15") | Out-Null
- $ddOutageEndTimeMM.Items.Add("30") | Out-Null
- $ddOutageEndTimeMM.Items.Add("45") | Out-Null
- $ddOutageEndTimeMM.Visible = $False
- $ddOutageEndTimeMM.DropDownHeight = 200
- $ddOutageEndTimeMM.AutoSize = $True
- $ddOutageEndTimeMM.location = new-object system.drawing.point(240,540)
- $ddOutageEndTimeMM.Font = "Microsoft Sans Serif,10"
- $ddOutageEndTimeMM.Tag = '1'
- $Form.controls.Add($ddOutageEndTimeMM)
- $rbOutageEndTimeAM = New-Object system.windows.Forms.RadioButton
- $rbOutageEndTimeAM.Text = "AM"
- $rbOutageEndTimeAM.AutoSize = $True
- $rbOutageEndTimeAM.Width = 10
- $rbOutageEndTimeAM.Height = 22
- $rbOutageEndTimeAM.location = new-object system.drawing.point(10,10)
- $rbOutageEndTimeAM.Font = "Microsoft Sans Serif,10"
- # $rbOutageEndTimeAM.add_click($radioButtons_CheckedChangedEndAMPM)
- $rbOutageEndTimePM = New-Object system.windows.Forms.RadioButton
- $rbOutageEndTimePM.Text = "PM"
- $rbOutageEndTimePM.AutoSize = $True
- $rbOutageEndTimePM.Checked = $True
- $rbOutageEndTimePM.Width = 15
- $rbOutageEndTimePM.Height = 22
- $rbOutageEndTimePM.location = new-object system.drawing.point(55,10)
- $rbOutageEndTimePM.Font = "Microsoft Sans Serif,10"
- # $rbOutageEndTimePM.add_click($radioButtons_CheckedChangedEndAMPM)
- $rbGroupBoxEndAMPM = New-Object Windows.Forms.Panel
- $rbGroupBoxEndAMPM.Text = ""
- $rbGroupBoxEndAMPM.Visible = $False
- $rbGroupBoxEndAMPM.Left = 280
- $rbGroupBoxEndAMPM.Top = 532
- $rbGroupBoxEndAMPM.Width = 100
- $rbGroupBoxEndAMPM.Height = 30
- $rbGroupBoxEndAMPM.Controls.Add($rbOutageEndTimeAM)
- $rbGroupBoxEndAMPM.Controls.Add($rbOutageEndTimePM)
- $rbGroupBoxEndAMPM.Tag = '1'
- $form.controls.add($rbGroupBoxEndAMPM)
- $txtYou = New-Object system.windows.Forms.RichTextBox
- $txtYou.Width = 300
- $txtYou.Height = 100
- $txtYou.Multiline = $True
- $txtYou.location = new-object system.drawing.point(200,600)
- $txtYou.Font = "Microsoft Sans Serif,10"
- $txtYou.Text ="Any issues please contact IT Support"
- $Form.controls.Add($txtYou)
- $pbBanner = New-Object System.Windows.Forms.PictureBox
- $pbBanner.Width = 500
- $pbBanner.Height = 140
- $pbBanner.location = new-object system.drawing.point(200,720)
- $pbBanner.ImageLocation = "$script:BannerInformation"
- $pbBanner.Image = [System.Drawing.Image]::Fromfile("$script:BannerInformation")
- $Form.controls.Add($pbBanner)
- $ddSection1 = new-object System.Windows.Forms.ComboBox
- $ddSection1.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddSection1.Location = new-object System.Drawing.Size(550,160)
- $ddSection1.Size = new-object System.Drawing.Size(30,21)
- $ddSection1.Items.Add("1") | Out-Null
- $ddSection1.Items.Add("2") | Out-Null
- $ddSection1.Items.Add("3") | Out-Null
- $ddSection1.SelectedIndex=0
- $form.Controls.Add($ddSection1)
- $ddSection2 = new-object System.Windows.Forms.ComboBox
- $ddSection2.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddSection2.Location = new-object System.Drawing.Size(550,181)
- $ddSection2.Size = new-object System.Drawing.Size(30,21)
- $ddSection2.Items.Add("1") | Out-Null
- $ddSection2.Items.Add("2") | Out-Null
- $ddSection2.Items.Add("3") | Out-Null
- $ddSection2.SelectedIndex=0
- $ddSection2.Tag = ""
- $form.Controls.Add($ddSection2)
- $ddSection3 = new-object System.Windows.Forms.ComboBox
- $ddSection3.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddSection3.Location = new-object System.Drawing.Size(550,202)
- $ddSection3.Size = new-object System.Drawing.Size(30,21)
- $ddSection3.Items.Add("1") | Out-Null
- $ddSection3.Items.Add("2") | Out-Null
- $ddSection3.Items.Add("3") | Out-Null
- $ddSection3.Tag = ""
- $ddSection3.SelectedIndex=0
- $form.Controls.Add($ddSection3)
- $ddSection4 = new-object System.Windows.Forms.ComboBox
- $ddSection4.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddSection4.Location = new-object System.Drawing.Size(550,223)
- $ddSection4.Size = new-object System.Drawing.Size(30,21)
- $ddSection4.Items.Add("1") | Out-Null
- $ddSection4.Items.Add("2") | Out-Null
- $ddSection4.Items.Add("3") | Out-Null
- $ddSection4.SelectedIndex=0
- $ddSection4.Tag = ""
- $form.Controls.Add($ddSection4)
- $ddSection5 = new-object System.Windows.Forms.ComboBox
- $ddSection5.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
- $ddSection5.Location = new-object System.Drawing.Size(550,244)
- $ddSection5.Size = new-object System.Drawing.Size(30,21)
- $ddSection5.Items.Add("1") | Out-Null
- $ddSection5.Items.Add("2") | Out-Null
- $ddSection5.Items.Add("3") | Out-Null
- $ddSection5.SelectedIndex=0
- $ddSection5.Tag = ""
- $form.Controls.Add($ddSection5)
- $txtOutageIMG1 = New-Object system.windows.Forms.ListBox
- $txtOutageIMG1.Width = 370
- $txtOutageIMG1.Height = 105
- $txtOutageIMG1.location = new-object system.drawing.point(580,160)
- $txtOutageIMG1.Font = "Microsoft Sans Serif,12"
- $Form.controls.Add($txtOutageIMG1)
- $txtOutageAtt = New-Object system.windows.Forms.ListBox
- $txtOutageAtt.Width = 400
- $txtOutageAtt.Height = 85
- $txtOutageAtt.location = new-object system.drawing.point(550,280)
- $txtOutageAtt.Font = "Microsoft Sans Serif,10"
- $Form.controls.Add($txtOutageAtt)
- $rbNotificationTypeI = New-Object system.windows.Forms.RadioButton
- $rbNotificationTypeI.Text = "Normal"
- $rbNotificationTypeI.Tag= 'Normal'
- $rbNotificationTypeI.AutoSize = $True
- $rbNotificationTypeI.Width = 100
- $rbNotificationTypeI.Height = 22
- $rbNotificationTypeI.location = new-object system.drawing.point(10,20)
- $rbNotificationTypeI.Font = "Microsoft Sans Serif,10"
- $rbNotificationTypeI.Checked = $True
- $rbNotificationTypeI.add_click($radioButtons_CheckedChanged)
- $rbNotificationTypeW = New-Object system.windows.Forms.RadioButton
- $rbNotificationTypeW.Text = "High"
- $rbNotificationTypeW.AutoSize = $True
- $rbNotificationTypeW.Tag= 'High'
- $rbNotificationTypeW.Width = 100
- $rbNotificationTypeW.Height = 22
- $rbNotificationTypeW.location = new-object system.drawing.point(10,40)
- $rbNotificationTypeW.Font = "Microsoft Sans Serif,10"
- $rbNotificationTypeW.add_click($radioButtons_CheckedChanged)
- $rbGroupBox = New-Object Windows.Forms.GroupBox
- $rbGroupBox.Text = "Notification Priority"
- $rbGroupBox.Left = 810
- $rbGroupBox.Top = 35
- $rbGroupBox.Width = 150
- $rbGroupBox.Height = 70
- $rbGroupBox.Controls.Add($rbNotificationTypeI)
- $rbGroupBox.Controls.Add($rbNotificationTypeW)
- $form.controls.add($rbGroupbox)
- $btnSend = New-Object system.windows.Forms.Button
- $btnSend.Text = "Send"
- $btnSend.Width = 60
- $btnSend.Height = 30
- $btnSend.Visible = $False
- $btnSend.location = new-object system.drawing.point(800,680)
- $btnSend.Font = "Microsoft Sans Serif,10"
- $btnSend.PerformClick()
- $btnSend.DialogResult=[System.Windows.Forms.DialogResult]::OK
- $Form.controls.Add($btnSend)
- $btnPeerReview = New-Object system.windows.Forms.Button
- $btnPeerReview.Text = "Peer Review"
- $btnPeerReview.Width = 100
- $btnPeerReview.Height = 30
- $btnPeerReview.location = new-object system.drawing.point(700,680)
- $btnPeerReview.Font = "Microsoft Sans Serif,10"
- $btnPeerReview.PerformClick()
- $btnPeerReview.Add_Click({Send-Email -PeerReview "True"})
- $Form.controls.Add($btnPeerReview)
- $btnCancel = New-Object system.windows.Forms.Button
- $btnCancel.Text = "Cancel"
- $btnCancel.Width = 60
- $btnCancel.Height = 30
- $btnCancel.location = new-object system.drawing.point(880,680)
- $btnCancel.Font = "Microsoft Sans Serif,10"
- $btnCancel.DialogResult=[System.Windows.Forms.DialogResult]::Cancel
- $Form.controls.Add($btnCancel)
- $btnBrowseImg = New-Object system.windows.Forms.Button
- $btnBrowseImg.Text = "Image Picker"
- $btnBrowseImg.Width = 200
- $btnBrowseImg.Height = 30
- $btnBrowseImg.location = new-object system.drawing.point(550,120)
- $btnBrowseImg.Font = "Microsoft Sans Serif,10"
- $btnBrowseImg.Add_Click({Get-Filename})
- $Form.controls.Add($btnBrowseImg)
- $btnBrowseAtt = New-Object system.windows.Forms.Button
- $btnBrowseAtt.Text = "Attachment Picker"
- $btnBrowseAtt.Width = 200
- $btnBrowseAtt.Height = 30
- $btnBrowseAtt.location = new-object system.drawing.point(750,120)
- $btnBrowseAtt.Font = "Microsoft Sans Serif,10"
- $btnBrowseAtt.Add_Click({Get-FilenameDoc})
- $Form.controls.Add($btnBrowseAtt)
- #region CALENDAR
- $cal = New-Object Windows.Forms.MonthCalendar;
- $cal.SetDate($DateSelected);
- $cal.TodayDate = $TodayDate;
- if($SelectionCount -lt 1){$SelectionCount = [int]::MaxValue;}
- $cal.MaxSelectionCount = $SelectionCount;
- $cal.MinDate = $MinDate;
- $cal.MaxDate = $MaxDate;
- $cal.ScrollChange = $ScrollBy;
- $cal.ShowTodayCircle = $True;
- if($FirstDayofWeek -eq -1){$FirstDayofWeek = [System.Windows.Forms.Day]::Default}
- $cal.FirstDayofWeek = [System.Windows.Forms.Day]$FirstDayofWeek;
- $cal.ShowWeekNumbers = $WeekNumbers;
- $cal.location = new-object system.drawing.point(570,370)
- if($NoTodayCircle){$cal.ShowTodayCircle = $False}
- switch -regex ($DisplayMode)
- {
- "^1$" {$cal.CalendarDimensions = "1,1"}
- "^2$" {$cal.CalendarDimensions = "2,1"}
- "^3$" { $cal.CalendarDimensions = "3,1"}
- "^4$" {$cal.CalendarDimensions = "2,2"}
- "^[56]$" {$cal.CalendarDimensions = "3,2"}
- "^[78]$" {$cal.CalendarDimensions = "4,2"}
- "^9$" {$cal.CalendarDimensions = "3,3"}
- "^1[012]$" {$cal.CalendarDimensions = "4,3"}
- "^16$" {$cal.CalendarDimensions = "4,4"}
- default {$cal.CalendarDimensions = "4,3"}
- }
- $Global:lastClick = (Get-Date)
- $cal.Add_DateSelected({
- if ((Get-Date) -lt $Global:lastClick.AddSeconds(1) -and $Global:lastDate.Start.Equals($cal.SelectionRange.Start) -and $Global:lastDate.End.Equals($cal.SelectionRange.End))
- {
- Get-SuffixAndClipboard
- }
- $Global:lastDate = $cal.SelectionRange
- $Global:lastClick = Get-Date
- })
- $form.Controls.add($cal)
- #endregion CALENDAR
- $btnEmailTo = New-Object system.windows.Forms.Button
- $btnEmailTo.Text = "Address Picker"
- $btnEmailTo.Width = 200
- $btnEmailTo.Height = 25
- $btnEmailTo.location = new-object system.drawing.point(250,10)
- $btnEmailTo.Font = "Microsoft Sans Serif,10"
- $btnEmailTo.Add_Click({Get-Addresses})
- $Form.controls.Add($btnEmailTo)
- $Form.Add_Shown({$form.Activate()})
- $dialogResult = $form.ShowDialog()
- $Form.CancelButton = $btnCancel
- $Form.AcceptButton = $btnSend
- #region FORM SUBMIT
- if ($dialogResult -eq "Yes") {
- if ($rbNotificationTypeI.Checked){
- Set-Variable -name NotificationType -Value "Normal"}
- elseif ($rbNotificationTypeW.Checked){
- Set-Variable -Name NotificationType -Value "High"}
- if ($cbAffectedServices.Checked -eq $False) {
- $lblAffectedServices.Text = ""
- $txtAffectedServices.Text = ""}
- if ($cbOutage1.Checked -eq $False) {
- $lblOutage1.Text = ""
- $txtOutage.Text = ""}
- if ($cbYou.Checked -eq $False) {
- $lblYou.Text = ""
- $txtYou.Text = ""}
- if ($ddType.Text -eq "Outage") {
- $txtOutage.Text = ""
- if ($rbOutageStartTimePM.Checked -eq $True) {$script:rbOutageStartTimePM = $rbOutageStartTimePM.Text}
- elseif ($rbOutageStartTimeAM.Checked -eq $True) {$script:rbOutageStartTimeAM = $rbOutageStartTimeAM.Text}
- if ($rbOutageEndTimePM.Checked -eq $True) {$script:rbOutageEndTimePM = $rbOutageEndTimePM.Text}
- elseif ($rbOutageEndTimeAM.Checked -eq $True) {$script:rbOutageEndTimeAM = $rbOutageEndTimeAM.Text}
- }
- if ($dialogResult -eq "OK"){Send-Email}
- }
- if ($dialogResult -eq "OK") {
- if ($rbNotificationTypeI.Checked){
- Set-Variable -name NotificationType -Value "Normal"}
- elseif ($rbNotificationTypeW.Checked){
- Set-Variable -Name NotificationType -Value "High"}
- if ($cbAffectedServices.Checked -eq $False) {
- $lblAffectedServices.Text = ""
- $txtAffectedServices.Text = ""}
- if ($cbOutage1.Checked -eq $False) {
- $lblOutage1.Text = ""
- $txtOutage.Text = ""}
- if ($cbYou.Checked -eq $False) {
- $lblYou.Text = ""
- $txtYou.Text = ""}
- if ($ddType.Text -eq "Outage") {
- $txtOutage.Text = ""
- if ($rbOutageStartTimePM.Checked -eq $True) {$script:rbOutageStartTimeAMPM = $rbOutageStartTimePM.Text}
- elseif ($rbOutageStartTimeAM.Checked -eq $True) {$script:rbOutageStartTimeAMPM = $rbOutageStartTimeAM.Text}
- if ($rbOutageEndTimePM.Checked -eq $True) {$script:rbOutageEndTimeAMPM = $rbOutageEndTimePM.Text}
- elseif ($rbOutageEndTimeAM.Checked -eq $True) {$script:rbOutageEndTimeAMPM = $rbOutageEndTimeAM.Text}
- }
- if ($dialogResult -eq "OK"){Send-Email}
- }
- elseif ($dialogResult -eq "Cancel"){exit}
- #endregion FORM SUBMIT
- #endregion FORM
- clear-variable -name Body
- clear-variable -name OutageArray
- clear-variable -name AddressList
- clear-variable -name OutageArrayAtt
- clear-variable -name SectionArray
Advertisement
Add Comment
Please, Sign In to add comment