回复电子邮件powershell [英] Reply email powershell

查看:72
本文介绍了回复电子邮件powershell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次感谢StackOverflow的共同之处,我将询问方法".reply()".这是我正在尝试的代码:

Hi again StackOverflow's comunity, I will ask about method ".reply()". This is the code I am trying:

function Unread ($correo) {
    if(($correo -eq $null) -or ($correo.Unread.ToString() -like "False")){
        $Noleido = $false
    }else{  
        $Noleido = $true
     return $Noleido
    }
}

    $body = "Bla bla bla"
    $firma = "I am here"
    #$cuerpo = "A test ps"
    $subject = "Re: automated reply"
    $Outlook = New-Object -comObject Outlook.Application 
    $OutlookFolders = $Outlook.Session.Folders.Item($buzon1).Folders
    #Map la bandeja de entrada.
    $bandeja_de_entrada=$OutlookFolders.Item("INBOX_FOLDER")

    #Creamos el objeto que hace referencia a la bandeja de entrada y los mensajes que contiene.
    $all_mail=$bandeja_de_entrada.Items


foreach ($mail in $all_mail){ 
    $flag1 = Unread($mail)
    if($flag1 -eq $true){     
       #$mail.to = ""         
       $mail.body =" $cuerpo" +"$firma"
       $mail.subject = $subject
       $mail.reply()
   }
}

不发送电子邮件.

解决了一个问题

推荐答案

方法 reply 创建一个MailItem,该MailItem会根据原始邮件预先填充必要的属性.

The method reply creates a MailItem prepopulated with the necessary properties based on the original mail.

如果将通过 reply 方法创建的MailItem保存到变量,则可以使用 send 方法实际发送答复.

If you save the MailItem created by the reply method to a variable you can then use the method send to actually send the reply.

修改脚本以使其类似于以下内容可能会起作用.

Modifying your script to look something like the following would probably work.

$body = "Bla bla bla"
    $firma = "I am here"
    $subject = "A test ps"
    $Outlook = New-Object -comObject Outlook.Application 
    $OutlookFolders = $Outlook.Session.Folders.Item($buzon1).Folders
    #Map la bandeja de entrada.
    $bandeja_de_entrada=$OutlookFolders.Item("INBOX_FOLDER")

    #Creamos el objeto que hace referencia a la bandeja de entrada y los mensajes que contiene.
    $all_mail=$bandeja_de_entrada.Items

    foreach ($mail in $all_mail){      
       #$mail.to = ""
       $reply = $mail.reply()
       $reply.body = " $cuerpo $firma"
       $reply.subject = $subject
       $reply.send()
    }

如果要包括原始消息而不是覆盖原始消息,则可以将 $ reply.body 行更改为类似的内容;

If you want to include the original message instead of overwriting it you could change the $reply.body-line to something like this;

$reply.body = $reply.body + " $cuerpo $firma"

这篇关于回复电子邮件powershell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆