Hi, we are making automated scripts to send a text file with some mail addresesses to another company to inject those mails address into her exchange server.
The PS script what we use are this:
<# script de automatización de envío de correo Desarrollado en el Dpto de Operaciones Soluciones IT (c) 2014 Version 1.00 #> Clear-Host Write-Host "Script de envío de archivo de contactos" -ForeGroundColor Magenta Write-Host "Creado por Alpha Systems S.R.L. (c) 2014" -ForeGroundColor Magenta Write-Host " " Write-Host " "<# Solicitamos los datos para el envío de los correos #> Write-Host -NoNewLine "Ingrese el fqdn del dominio de correo: " -ForeGroundColor Yellow;$Suffix=Read-Host Write-Host -NoNewLine "Ingrese el nombre de nuestro servidor Exchange: "-ForeGroundColor Yellow; $Server=Read-Host Write-Host -NoNewLine "Ingrese la dirección de correo destino: "-ForeGroundColor Yellow;$Receipt_Mail_Address=Read-Host Write-Host -NoNewLine "Ingrese la dirección de correo remitente: "-ForeGroundColor Yellow;$Sender_Mail_Address=Read-Host Write-Host " " Write-Host " "<# Armamos el correo electrónico y lo enviamos #> $filename=“c:\Sync\Contacts-"+$Suffix+".txt” $msg=new-object Net.Mail.MailMessage $att=new-object Net.Mail.Attachment($filename) $smtp=new-object Net.Mail.SmtpClient($Server) $msg.From=$Sender_Mail_Address $msg.To.Add($Receipt_Mail_Address) $msg.Subject = “Correo automatizado – Contacts-"+$Suffix+".TXT” $msg.Body=“Envío automatizado del archivo Contacts-"+$Suffix+".TXT” $msg.Attachments.Add($filename) $smtp.Send($msg) Write-Host "Enviando Correo automatizado, por favor espere ... " -ForeGroundColor Green Write-Host " " Write-Host " " Write-Host "Correo enviado" -ForeGroundColor Green
In the script we are asking for the name of the server, the sender and destination mail address.
In exchange Server 2010 this PS script works fine, but in Exchange 2013 SP1 does not work, we receive the following error message
Exception calling "Send" with "1" argument(s): "Mailbox unavailable. The server response was: 5.7.1 Unable to relay" At C:\sync\RobotSendAutoMail.ps1:44 char:1+ $smtp.Send($msg)+ ~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException+ FullyQualifiedErrorId : SmtpFailedRecipientException
We need what this script works again in Exchange 2013
Raulito