none
Форма ответов RRS feed

  • Вопрос

  • Здравствуйте.

    Есть скрипт:

    $body= get-content "C:\BC\HTML\num-test.html"
    $content = "C:\BC\NUM\num-test.txt"
    $encoding = [System.Text.Encoding]::UTF8
    
    Get-Content $content | foreach-object {Send-Mailmessage -To $_ -From "Проверка кодировки <bc-newsletter@domain.local>"  -Encoding $encoding -Subject "Просьба проверить" -Body $body -BodyAsHTML:$True -Priority High -DeliveryNotificationOption Onsuccess -SMTPServer 10.8.254.7}

    Как сделать форму для пользователя:

    1. Пользователь запускает скрипт

    2. Скрипт просит указать файл рассылки адресов через проводник

    3. Скрипт просит вести тему письма

    4. Скрипт просит файл тела письма в формате html также указывается через проводник

    5. Кнопка отправить становится активной

    Заранее благодарен.


    Сначала Вас игнорируют, потом над Вами смеются, потом с Вами борются, а затем Вы победили.


    • Изменено MR.Minion 28 сентября 2013 г. 8:49
    28 сентября 2013 г. 7:49

Ответы

  • Код сгенерирован с помощью PrimalForms Community Edition.

    Function Get-FileName($InitialDirectory,$Title)
    {   
    	$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
    	$OpenFileDialog.InitialDirectory = $initialDirectory
    	$OpenFileDialog.Filter = "All files (*.*)| *.*"
    	$OpenFileDialog.Title = $Title
    	$OpenFileDialog.ShowDialog() | Out-Null
    	$OpenFileDialog.Filename
    }
    
    Function Check {
    	$subject = $richTextBox1.Text -match "\w"
    	$addr = Test-Path -LiteralPath $richTextBox2.Text
    	$body = Test-Path -LiteralPath $richTextBox3.Text
    	if ($subject -and $addr -and $body) {
    		$button3.Enabled = $true
    	}
    	else {
    		$button3.Enabled = $false
    	}
    }
    
    Add-Type -Assembly System.Windows.Forms
    Add-Type -Assembly System.Drawing
    #Generated Form Function
    function GenerateForm {
    
    #region Generated Form Objects
    $form1 = New-Object System.Windows.Forms.Form
    $button3 = New-Object System.Windows.Forms.Button
    $button2 = New-Object System.Windows.Forms.Button
    $richTextBox3 = New-Object System.Windows.Forms.RichTextBox
    $button1 = New-Object System.Windows.Forms.Button
    $richTextBox2 = New-Object System.Windows.Forms.RichTextBox
    $label1 = New-Object System.Windows.Forms.Label
    $richTextBox1 = New-Object System.Windows.Forms.RichTextBox
    $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
    #endregion Generated Form Objects
    
    #----------------------------------------------
    #Generated Event Script Blocks
    #----------------------------------------------
    #Provide Custom Code for events specified in PrimalForms.
    $button3_OnClick= 
    {
    	$Encoding = [System.Text.Encoding]::UTF8
    	$Subject = $richTextBox1.Text
    	$Addr = Get-Content $richTextBox2.Text
    	$Body = Get-Content $richTextBox3.Text | Out-String
    	
    	Send-Mailmessage -To $Addr -From "Проверка кодировки <bc-newsletter@domain.local>" `
    		-Encoding $Encoding -Subject $Subject -Body $Body -BodyAsHTML `
    			-Priority High -DeliveryNotificationOption OnSuccess -SMTPServer 10.8.254.7
    }
    
    $button1_OnClick= 
    {
    	$richTextBox2.Text = Get-FileName -Title "Файл расслыки адресов"
    	Check
    }
    
    $button2_OnClick= 
    {
    	$richTextBox3.Text = Get-FileName -Title "Файл тела письма в формате html"
    	Check
    }
    
    $handler_label1_Click= 
    {
    #TODO: Place custom script here
    
    }
    
    $handler_form1_Load= 
    {
    #TODO: Place custom script here
    
    }
    
    $OnLoadForm_StateCorrection=
    {#Correct the initial state of the form to prevent the .Net maximized form issue
    	$form1.WindowState = $InitialFormWindowState
    }
    
    #----------------------------------------------
    #region Generated Form Code
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 239
    $System_Drawing_Size.Width = 512
    $form1.ClientSize = $System_Drawing_Size
    $form1.DataBindings.DefaultDataSourceUpdateMode = 0
    $form1.FormBorderStyle = 2
    $form1.Name = "form1"
    $form1.Text = "Send Mail Message"
    $form1.add_Load($handler_form1_Load)
    
    
    $button3.DataBindings.DefaultDataSourceUpdateMode = 0
    $button3.Enabled = $False
    $button3.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",14,1,3,0)
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 184
    $System_Drawing_Point.Y = 194
    $button3.Location = $System_Drawing_Point
    $button3.Name = "button3"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 33
    $System_Drawing_Size.Width = 118
    $button3.Size = $System_Drawing_Size
    $button3.TabIndex = 6
    $button3.Text = "Send"
    $button3.UseVisualStyleBackColor = $True
    $button3.add_Click($button3_OnClick)
    
    $form1.Controls.Add($button3)
    
    
    $button2.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 412
    $System_Drawing_Point.Y = 146
    $button2.Location = $System_Drawing_Point
    $button2.Name = "button2"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 80
    $button2.Size = $System_Drawing_Size
    $button2.TabIndex = 5
    $button2.Text = "Open"
    $button2.UseVisualStyleBackColor = $True
    $button2.add_Click($button2_OnClick)
    
    $form1.Controls.Add($button2)
    
    $richTextBox3.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 20
    $System_Drawing_Point.Y = 148
    $richTextBox3.Location = $System_Drawing_Point
    $richTextBox3.Multiline = $False
    $richTextBox3.Name = "richTextBox3"
    $richTextBox3.ReadOnly = $True
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 373
    $richTextBox3.Size = $System_Drawing_Size
    $richTextBox3.TabIndex = 4
    $richTextBox3.Text = "Выберите файл для тела письма в формате html"
    
    $form1.Controls.Add($richTextBox3)
    
    
    $button1.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 412
    $System_Drawing_Point.Y = 98
    $button1.Location = $System_Drawing_Point
    $button1.Name = "button1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 80
    $button1.Size = $System_Drawing_Size
    $button1.TabIndex = 3
    $button1.Text = "Open"
    $button1.UseVisualStyleBackColor = $True
    $button1.add_Click($button1_OnClick)
    
    $form1.Controls.Add($button1)
    
    $richTextBox2.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 20
    $System_Drawing_Point.Y = 98
    $richTextBox2.Location = $System_Drawing_Point
    $richTextBox2.Multiline = $False
    $richTextBox2.Name = "richTextBox2"
    $richTextBox2.ReadOnly = $True
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 373
    $richTextBox2.Size = $System_Drawing_Size
    $richTextBox2.TabIndex = 2
    $richTextBox2.Text = "Выберите файл для рассылки адресов"
    
    $form1.Controls.Add($richTextBox2)
    
    $label1.DataBindings.DefaultDataSourceUpdateMode = 0
    $label1.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",14,1,3,0)
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 184
    $System_Drawing_Point.Y = 9
    $label1.Location = $System_Drawing_Point
    $label1.Name = "label1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 118
    $label1.Size = $System_Drawing_Size
    $label1.TabIndex = 1
    $label1.Text = "Subject"
    $label1.TextAlign = 32
    $label1.add_Click($handler_label1_Click)
    
    $form1.Controls.Add($label1)
    
    $richTextBox1.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 20
    $System_Drawing_Point.Y = 45
    $richTextBox1.Location = $System_Drawing_Point
    $richTextBox1.Multiline = $False
    $richTextBox1.Name = "richTextBox1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 19
    $System_Drawing_Size.Width = 480
    $richTextBox1.Size = $System_Drawing_Size
    $richTextBox1.TabIndex = 0
    $richTextBox1.Text = ""
    $richTextBox1.Add_TextChanged({
    	Check
    })
    $form1.Controls.Add($richTextBox1)
    
    #endregion Generated Form Code
    
    #Save the initial state of the form
    $InitialFormWindowState = $form1.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $form1.add_Load($OnLoadForm_StateCorrection)
    #Show the Form
    $form1.ShowDialog()| Out-Null
    
    } #End Function
    
    #Call the Function
    GenerateForm
    

    • Помечено в качестве ответа MR.Minion 28 сентября 2013 г. 11:47
    28 сентября 2013 г. 9:37
    Отвечающий

Все ответы

  • Код сгенерирован с помощью PrimalForms Community Edition.

    Function Get-FileName($InitialDirectory,$Title)
    {   
    	$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
    	$OpenFileDialog.InitialDirectory = $initialDirectory
    	$OpenFileDialog.Filter = "All files (*.*)| *.*"
    	$OpenFileDialog.Title = $Title
    	$OpenFileDialog.ShowDialog() | Out-Null
    	$OpenFileDialog.Filename
    }
    
    Function Check {
    	$subject = $richTextBox1.Text -match "\w"
    	$addr = Test-Path -LiteralPath $richTextBox2.Text
    	$body = Test-Path -LiteralPath $richTextBox3.Text
    	if ($subject -and $addr -and $body) {
    		$button3.Enabled = $true
    	}
    	else {
    		$button3.Enabled = $false
    	}
    }
    
    Add-Type -Assembly System.Windows.Forms
    Add-Type -Assembly System.Drawing
    #Generated Form Function
    function GenerateForm {
    
    #region Generated Form Objects
    $form1 = New-Object System.Windows.Forms.Form
    $button3 = New-Object System.Windows.Forms.Button
    $button2 = New-Object System.Windows.Forms.Button
    $richTextBox3 = New-Object System.Windows.Forms.RichTextBox
    $button1 = New-Object System.Windows.Forms.Button
    $richTextBox2 = New-Object System.Windows.Forms.RichTextBox
    $label1 = New-Object System.Windows.Forms.Label
    $richTextBox1 = New-Object System.Windows.Forms.RichTextBox
    $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
    #endregion Generated Form Objects
    
    #----------------------------------------------
    #Generated Event Script Blocks
    #----------------------------------------------
    #Provide Custom Code for events specified in PrimalForms.
    $button3_OnClick= 
    {
    	$Encoding = [System.Text.Encoding]::UTF8
    	$Subject = $richTextBox1.Text
    	$Addr = Get-Content $richTextBox2.Text
    	$Body = Get-Content $richTextBox3.Text | Out-String
    	
    	Send-Mailmessage -To $Addr -From "Проверка кодировки <bc-newsletter@domain.local>" `
    		-Encoding $Encoding -Subject $Subject -Body $Body -BodyAsHTML `
    			-Priority High -DeliveryNotificationOption OnSuccess -SMTPServer 10.8.254.7
    }
    
    $button1_OnClick= 
    {
    	$richTextBox2.Text = Get-FileName -Title "Файл расслыки адресов"
    	Check
    }
    
    $button2_OnClick= 
    {
    	$richTextBox3.Text = Get-FileName -Title "Файл тела письма в формате html"
    	Check
    }
    
    $handler_label1_Click= 
    {
    #TODO: Place custom script here
    
    }
    
    $handler_form1_Load= 
    {
    #TODO: Place custom script here
    
    }
    
    $OnLoadForm_StateCorrection=
    {#Correct the initial state of the form to prevent the .Net maximized form issue
    	$form1.WindowState = $InitialFormWindowState
    }
    
    #----------------------------------------------
    #region Generated Form Code
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 239
    $System_Drawing_Size.Width = 512
    $form1.ClientSize = $System_Drawing_Size
    $form1.DataBindings.DefaultDataSourceUpdateMode = 0
    $form1.FormBorderStyle = 2
    $form1.Name = "form1"
    $form1.Text = "Send Mail Message"
    $form1.add_Load($handler_form1_Load)
    
    
    $button3.DataBindings.DefaultDataSourceUpdateMode = 0
    $button3.Enabled = $False
    $button3.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",14,1,3,0)
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 184
    $System_Drawing_Point.Y = 194
    $button3.Location = $System_Drawing_Point
    $button3.Name = "button3"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 33
    $System_Drawing_Size.Width = 118
    $button3.Size = $System_Drawing_Size
    $button3.TabIndex = 6
    $button3.Text = "Send"
    $button3.UseVisualStyleBackColor = $True
    $button3.add_Click($button3_OnClick)
    
    $form1.Controls.Add($button3)
    
    
    $button2.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 412
    $System_Drawing_Point.Y = 146
    $button2.Location = $System_Drawing_Point
    $button2.Name = "button2"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 80
    $button2.Size = $System_Drawing_Size
    $button2.TabIndex = 5
    $button2.Text = "Open"
    $button2.UseVisualStyleBackColor = $True
    $button2.add_Click($button2_OnClick)
    
    $form1.Controls.Add($button2)
    
    $richTextBox3.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 20
    $System_Drawing_Point.Y = 148
    $richTextBox3.Location = $System_Drawing_Point
    $richTextBox3.Multiline = $False
    $richTextBox3.Name = "richTextBox3"
    $richTextBox3.ReadOnly = $True
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 373
    $richTextBox3.Size = $System_Drawing_Size
    $richTextBox3.TabIndex = 4
    $richTextBox3.Text = "Выберите файл для тела письма в формате html"
    
    $form1.Controls.Add($richTextBox3)
    
    
    $button1.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 412
    $System_Drawing_Point.Y = 98
    $button1.Location = $System_Drawing_Point
    $button1.Name = "button1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 80
    $button1.Size = $System_Drawing_Size
    $button1.TabIndex = 3
    $button1.Text = "Open"
    $button1.UseVisualStyleBackColor = $True
    $button1.add_Click($button1_OnClick)
    
    $form1.Controls.Add($button1)
    
    $richTextBox2.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 20
    $System_Drawing_Point.Y = 98
    $richTextBox2.Location = $System_Drawing_Point
    $richTextBox2.Multiline = $False
    $richTextBox2.Name = "richTextBox2"
    $richTextBox2.ReadOnly = $True
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 373
    $richTextBox2.Size = $System_Drawing_Size
    $richTextBox2.TabIndex = 2
    $richTextBox2.Text = "Выберите файл для рассылки адресов"
    
    $form1.Controls.Add($richTextBox2)
    
    $label1.DataBindings.DefaultDataSourceUpdateMode = 0
    $label1.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",14,1,3,0)
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 184
    $System_Drawing_Point.Y = 9
    $label1.Location = $System_Drawing_Point
    $label1.Name = "label1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 118
    $label1.Size = $System_Drawing_Size
    $label1.TabIndex = 1
    $label1.Text = "Subject"
    $label1.TextAlign = 32
    $label1.add_Click($handler_label1_Click)
    
    $form1.Controls.Add($label1)
    
    $richTextBox1.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 20
    $System_Drawing_Point.Y = 45
    $richTextBox1.Location = $System_Drawing_Point
    $richTextBox1.Multiline = $False
    $richTextBox1.Name = "richTextBox1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 19
    $System_Drawing_Size.Width = 480
    $richTextBox1.Size = $System_Drawing_Size
    $richTextBox1.TabIndex = 0
    $richTextBox1.Text = ""
    $richTextBox1.Add_TextChanged({
    	Check
    })
    $form1.Controls.Add($richTextBox1)
    
    #endregion Generated Form Code
    
    #Save the initial state of the form
    $InitialFormWindowState = $form1.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $form1.add_Load($OnLoadForm_StateCorrection)
    #Show the Form
    $form1.ShowDialog()| Out-Null
    
    } #End Function
    
    #Call the Function
    GenerateForm
    

    • Помечено в качестве ответа MR.Minion 28 сентября 2013 г. 11:47
    28 сентября 2013 г. 9:37
    Отвечающий
  • Код сгенерирован с помощью PrimalForms Community Edition.

    Function Get-FileName($InitialDirectory,$Title)
    {   
    	$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
    	$OpenFileDialog.InitialDirectory = $initialDirectory
    	$OpenFileDialog.Filter = "All files (*.*)| *.*"
    	$OpenFileDialog.Title = $Title
    	$OpenFileDialog.ShowDialog() | Out-Null
    	$OpenFileDialog.Filename
    }
    
    Function Check {
    	$subject = $richTextBox1.Text -match "\w"
    	$addr = Test-Path -LiteralPath $richTextBox2.Text
    	$body = Test-Path -LiteralPath $richTextBox3.Text
    	if ($subject -and $addr -and $body) {
    		$button3.Enabled = $true
    	}
    	else {
    		$button3.Enabled = $false
    	}
    }
    
    Add-Type -Assembly System.Windows.Forms
    Add-Type -Assembly System.Drawing
    #Generated Form Function
    function GenerateForm {
    
    #region Generated Form Objects
    $form1 = New-Object System.Windows.Forms.Form
    $button3 = New-Object System.Windows.Forms.Button
    $button2 = New-Object System.Windows.Forms.Button
    $richTextBox3 = New-Object System.Windows.Forms.RichTextBox
    $button1 = New-Object System.Windows.Forms.Button
    $richTextBox2 = New-Object System.Windows.Forms.RichTextBox
    $label1 = New-Object System.Windows.Forms.Label
    $richTextBox1 = New-Object System.Windows.Forms.RichTextBox
    $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
    #endregion Generated Form Objects
    
    #----------------------------------------------
    #Generated Event Script Blocks
    #----------------------------------------------
    #Provide Custom Code for events specified in PrimalForms.
    $button3_OnClick= 
    {
    	$Encoding = [System.Text.Encoding]::UTF8
    	$Subject = $richTextBox1.Text
    	$Addr = Get-Content $richTextBox2.Text
    	$Body = Get-Content $richTextBox3.Text | Out-String
    	
    	Send-Mailmessage -To $Addr -From "Проверка кодировки <bc-newsletter@domain.local>" `
    		-Encoding $Encoding -Subject $Subject -Body $Body -BodyAsHTML `
    			-Priority High -DeliveryNotificationOption OnSuccess -SMTPServer 10.8.254.7
    }
    
    $button1_OnClick= 
    {
    	$richTextBox2.Text = Get-FileName -Title "Файл расслыки адресов"
    	Check
    }
    
    $button2_OnClick= 
    {
    	$richTextBox3.Text = Get-FileName -Title "Файл тела письма в формате html"
    	Check
    }
    
    $handler_label1_Click= 
    {
    #TODO: Place custom script here
    
    }
    
    $handler_form1_Load= 
    {
    #TODO: Place custom script here
    
    }
    
    $OnLoadForm_StateCorrection=
    {#Correct the initial state of the form to prevent the .Net maximized form issue
    	$form1.WindowState = $InitialFormWindowState
    }
    
    #----------------------------------------------
    #region Generated Form Code
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 239
    $System_Drawing_Size.Width = 512
    $form1.ClientSize = $System_Drawing_Size
    $form1.DataBindings.DefaultDataSourceUpdateMode = 0
    $form1.FormBorderStyle = 2
    $form1.Name = "form1"
    $form1.Text = "Send Mail Message"
    $form1.add_Load($handler_form1_Load)
    
    
    $button3.DataBindings.DefaultDataSourceUpdateMode = 0
    $button3.Enabled = $False
    $button3.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",14,1,3,0)
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 184
    $System_Drawing_Point.Y = 194
    $button3.Location = $System_Drawing_Point
    $button3.Name = "button3"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 33
    $System_Drawing_Size.Width = 118
    $button3.Size = $System_Drawing_Size
    $button3.TabIndex = 6
    $button3.Text = "Send"
    $button3.UseVisualStyleBackColor = $True
    $button3.add_Click($button3_OnClick)
    
    $form1.Controls.Add($button3)
    
    
    $button2.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 412
    $System_Drawing_Point.Y = 146
    $button2.Location = $System_Drawing_Point
    $button2.Name = "button2"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 80
    $button2.Size = $System_Drawing_Size
    $button2.TabIndex = 5
    $button2.Text = "Open"
    $button2.UseVisualStyleBackColor = $True
    $button2.add_Click($button2_OnClick)
    
    $form1.Controls.Add($button2)
    
    $richTextBox3.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 20
    $System_Drawing_Point.Y = 148
    $richTextBox3.Location = $System_Drawing_Point
    $richTextBox3.Multiline = $False
    $richTextBox3.Name = "richTextBox3"
    $richTextBox3.ReadOnly = $True
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 373
    $richTextBox3.Size = $System_Drawing_Size
    $richTextBox3.TabIndex = 4
    $richTextBox3.Text = "Выберите файл для тела письма в формате html"
    
    $form1.Controls.Add($richTextBox3)
    
    
    $button1.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 412
    $System_Drawing_Point.Y = 98
    $button1.Location = $System_Drawing_Point
    $button1.Name = "button1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 80
    $button1.Size = $System_Drawing_Size
    $button1.TabIndex = 3
    $button1.Text = "Open"
    $button1.UseVisualStyleBackColor = $True
    $button1.add_Click($button1_OnClick)
    
    $form1.Controls.Add($button1)
    
    $richTextBox2.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 20
    $System_Drawing_Point.Y = 98
    $richTextBox2.Location = $System_Drawing_Point
    $richTextBox2.Multiline = $False
    $richTextBox2.Name = "richTextBox2"
    $richTextBox2.ReadOnly = $True
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 373
    $richTextBox2.Size = $System_Drawing_Size
    $richTextBox2.TabIndex = 2
    $richTextBox2.Text = "Выберите файл для рассылки адресов"
    
    $form1.Controls.Add($richTextBox2)
    
    $label1.DataBindings.DefaultDataSourceUpdateMode = 0
    $label1.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",14,1,3,0)
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 184
    $System_Drawing_Point.Y = 9
    $label1.Location = $System_Drawing_Point
    $label1.Name = "label1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 118
    $label1.Size = $System_Drawing_Size
    $label1.TabIndex = 1
    $label1.Text = "Subject"
    $label1.TextAlign = 32
    $label1.add_Click($handler_label1_Click)
    
    $form1.Controls.Add($label1)
    
    $richTextBox1.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 20
    $System_Drawing_Point.Y = 45
    $richTextBox1.Location = $System_Drawing_Point
    $richTextBox1.Multiline = $False
    $richTextBox1.Name = "richTextBox1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 19
    $System_Drawing_Size.Width = 480
    $richTextBox1.Size = $System_Drawing_Size
    $richTextBox1.TabIndex = 0
    $richTextBox1.Text = ""
    $richTextBox1.Add_TextChanged({
    	Check
    })
    $form1.Controls.Add($richTextBox1)
    
    #endregion Generated Form Code
    
    #Save the initial state of the form
    $InitialFormWindowState = $form1.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $form1.add_Load($OnLoadForm_StateCorrection)
    #Show the Form
    $form1.ShowDialog()| Out-Null
    
    } #End Function
    
    #Call the Function
    GenerateForm
    

    Спасибо за помощь и программу !

    Сначала Вас игнорируют, потом над Вами смеются, потом с Вами борются, а затем Вы победили.

    28 сентября 2013 г. 11:47
  • Не подскажите почему когда запускают скрипт из батника 

    powershell -command "& '.\sendingletters.ps1'"

    Нельзя выполнить действие вложить файл ?

    Также проблема скрипт отправляет всем письмо скопом то есть получается в Кому указаны все адреса как сделать чтобы отправлял по одному ?



    • Изменено MR.Minion 28 сентября 2013 г. 15:59
    28 сентября 2013 г. 15:37
  • Не подскажите почему когда запускают скрипт из батника 

    powershell -command "& '.\sendingletters.ps1'"

    Нельзя выполнить действие вложить файл ?

    Также проблема скрипт отправляет всем письмо скопом то есть получается в Кому указаны все адреса как сделать чтобы отправлял по одному ?



    Можно выполнить действие вложить файл.

    Поправьте строчку на :

    $Addr | Foreach {
    	Send-Mailmessage -To $_ -From "Проверка кодировки <bc-newsletter@domain.local>" `
    		-Encoding $Encoding -Subject $Subject -Body $Body -BodyAsHTML `
    			-Priority High -DeliveryNotificationOption OnSuccess -SMTPServer 10.8.254.7
    }
    

    29 сентября 2013 г. 7:16
    Отвечающий
  • Не подскажите почему когда запускают скрипт из батника 

    powershell -command "& '.\sendingletters.ps1'"

    Нельзя выполнить действие вложить файл ?

    Также проблема скрипт отправляет всем письмо скопом то есть получается в Кому указаны все адреса как сделать чтобы отправлял по одному ?



    Можно выполнить действие вложить файл.

    Поправьте строчку на :

    $Addr | Foreach {
    	Send-Mailmessage -To $_ -From "Проверка кодировки <bc-newsletter@domain.local>" `
    		-Encoding $Encoding -Subject $Subject -Body $Body -BodyAsHTML `
    			-Priority High -DeliveryNotificationOption OnSuccess -SMTPServer 10.8.254.7
    }

    Спасибо работает !

    • Изменено MR.Minion 29 сентября 2013 г. 9:09
    29 сентября 2013 г. 9:07