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()
}
}
Dont send the email.
Its solved in a answer
The method
replycreates a MailItem prepopulated with the necessary properties based on the original mail.If you save the MailItem created by the
replymethod to a variable you can then use the methodsendto actually send the reply.Modifying your script to look something like the following would probably work.
If you want to include the original message instead of overwriting it you could change the
$reply.body-line to something like this;