【问题标题】:Drag and drop outlook selected attachtment with powershell使用 powershell 拖放 Outlook 选定的附件
【发布时间】:2021-02-10 13:07:26
【问题描述】:

我已设法从邮件中获取所有附件并将其保存到某个位置。 现在我正在尝试将其拖放到列表框中。 现在它得到了所有的附件,但我只希望在 Outlook 消息中选择。

$outlook = New-Object -comobject outlook.application
$sel=$outlook.ActiveExplorer().selection 
    foreach ($s in $sel) {
      foreach ($at in $s.Attachments) 
        {if ($at.FileName -match 'SCAN_*') 
                 {$newname=[io.path]::ChangeExtension($Filesgo_listbox.SelectedItem,"PDF") 
                   if ($newname -NOTmatch "20*") {$newname= $DATUM + " " + $newname}
                   $name= join-path $curfil $newname }
            else {$name=join-path $curfil $at.FileName}
   

【问题讨论】:

  • 如果您已经在文件系统上序列化了附件,那么它们不再是附件,它们只是文件。因此,您需要从文件系统中选择它们。但是您没有从您的 GUI 中显示任何代码,因此,我们甚至看不到您在做什么。网络上有很多例子展示了从文件系统拖放到表单。只需搜索它们。

标签: powershell outlook attachment


【解决方案1】:

继续我的评论。

'PowerShell Drag & Drop files' winform

# Example 1
Function DragDropSample() 
{
    [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

    $form         = New-Object Windows.Forms.Form
    $form.text    = "Drag&Drop sample"
    $listBox      = New-Object Windows.Forms.ListBox
    $listBox.Dock = [System.Windows.Forms.DockStyle]::Fill

    $handler = {
        if ($_.Data.GetDataPresent([Windows.Forms.DataFormats]::FileDrop)) {
            foreach ($filename in $_.Data.GetData([Windows.Forms.DataFormats]::FileDrop)) {
                $listBox.Items.Add($filename)
            }
        }
    }
    $form.AllowDrop = $true
    $form.Add_DragEnter($handler)
    $form.Controls.Add($listBox)
    $form.ShowDialog()
}

DragDropSample | Out-Null

SP 上的类似问答:

PowerShell - DataGridView Windows Form Drag and Drop Issue

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-01
    • 1970-01-01
    • 2016-09-21
    • 1970-01-01
    • 1970-01-01
    • 2020-09-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多