Usuario
Enviar Mail con imágenes.

Pregunta
-
Hola estoy intentando enviar un mail con imágenes en el body del mismo, pero no consigo que salgan las imágenes,
Me podríais decir como puedo hacer esta parte, pues enviar el mensaje se envia perfectamenten hasta incluso con ficheros adjuntos, pero las imágenes que contiene dicho mensaje. no hay manera...
Asi es como lo estoy haciendo:
$runDateTime = Get-Date
$smtp = "smtp.office365.com"
$to = "xxx@xxxxx.com"
$cc = ""
$from = "xxx@xxxxx.com"
$subject = "Texto de Asunto"
$attachmentLocation = "C:\Users\Administrator\Desktop\documento.pdf"
$body = "<center>"
$body += "<img src='/Imagen.png'>"
$body += "</center>"
$login = "xxx@xxxxx.com"
$password = "xxxxxx"
$secureStringPwd = $password | ConvertTo-SecureString -AsPlainText -Force
$credentials = New-Object System.Management.Automation.Pscredential -Argumentlist $login,$secureStringPwd
Send-MailMessage -SmtpServer $smtp -Port 587 -to $to -from $from -Subject $subject -Body $body -BodyAsHtml -Attachments $attachmentLocation -UseSsl -Credential $credentials
Muchas gracias.
- Editado Aldopo lunes, 30 de diciembre de 2019 21:08
Todas las respuestas
-
-
Muy buenos dias Giuliana
$runDateTime = Get-Date
Lo primero muchísimas gracias por tu respuesta, la cual he implementado y nada, sigue sin enviar, algo debo estar haciendo mal:
$smtp = "smtp.office365.com"
$to = "xxx@xxx.com"
$cc = ""
$from = "xxx@xxx.com"
$subject = "Hola soy el Asunto....."
$attachmentLocation = "C:\Users\Administrator\Desktop\documento.pdf"
$att = new-object Net.Mail.Attachment("Foto.png")
$att.ContentId = "imagen"
$body = "<center>"
$body += "<img src='cid:att'/>"
$body += "</center>"
$login = "xxx@xxx.com"
$password = "XxXxXx"
$secureStringPwd = $password | ConvertTo-SecureString -AsPlainText -Force
$credentials = New-Object System.Management.Automation.Pscredential -Argumentlist $login,$secureStringPwd
Send-MailMessage -SmtpServer $smtp -Port 587 -to $to -from $from -Subject $subject -Body $body -BodyAsHtml -Attachments $attachmentLocation -UseSsl -Credential $credentialsNo se si estoy escribiendo algo mal, pero sigue sin enviar. Seguro que es la desesperación de las horas que llevo invertidas en este proceso... :(
Muchas gracias por tu ayuda.
-