This project is read-only.

Failed to read attachment from email

Jan 4, 2013 at 4:35 PM

Hi, 

I have a application that failed to read attachment from email sent with PowerShell using Send-MailMessage.


Sample form send email from powershell:
$secpasswd = ConvertTo-SecureString "password" -AsPlainText -Force$mycreds = New-Object System.Management.Automation.PSCredential ("mail.email.com.br", $secpasswd)
Send-MailMessage -To "email@gmail.com" -Subject "Subject" -SmtpServer "smtp.server.net" -credential $mycreds -from "from@mail.email.com.br" -attachment "C:\scripts\file.txt" -UseSSL

 

Sample to read inbox in c#

ImapX.ImapClient client = new ImapX.ImapClient(sHost, Convert.ToInt16(sPort), bSSL);            if (client.Connection()){ if (client.LogIn(sUser, sPwd)) { ImapX.MessageCollection emailsNaoLidos = client.Folders[sFolder].Search("UNSEEN", true);
foreach (var mail in emailsNaoLidos) { mail.Attachments // the attachements value is 0 } }}

 

I can read the email, but the attachments is empty. That only happens when I send email using PowerShell.

 

could help me?

Thanks

Jan 7, 2013 at 3:43 PM

Hi wilhelmmeier,

the problem you have described occured because the attachments added to messages by Powershell did not contain some important headers that mark them as attachments. Nevertheless it's possible to recognize them.

The problem is fixed now, please update to the latest version of ImapX that was released today.

 

Best regards,

Pavel Azanov