且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

回复电子邮件powershell

更新时间:2023-02-25 10:10:47

方法 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"