My issue at the moment,is if an attachment is being used, the email does not get send, and there is no error message. The file name is correct, I have verified that. Whith this code I get no email, but no error message as well.
Here is an example
string strdtfile = DateTime.Now.ToString("yyyyMMddHHmmss");
string FilePath = @Server.MapPath("~/Temp/" + strdtfile + ".pdf");
currentReport.ExportToPdf(FilePath);
var mymessage = new MimeMailMessage();
mymessage.From = new MimeMailAddress(Mail);
mymessage.Subject = "Web Purchase Receipt " + DateTime.Now.ToString("yyyyMMdd");
mymessage.To.Add(Session["email"].ToString());
mymessage.Body = "";
mymessage.IsBodyHtml = true;
mymessage.To.Add(Session["email"].ToString());
var mailer = new MimeMailer(Host, 465)
{
User = User,
Password = Pass,
EnableImplicitSsl = true,
AuthenticationMode = AuthenticationType.Base64
};
mymessage.Attachments.Add(new MimeAttachment(FilePath)); ((SmtpSocketClient)mailer).SslType = SslMode.Ssl; mailer.SendCompleted += SendCompleted; mailer.SendMailAsync(mymessage);
Had the same issue, mail server reported: "554 Too long line was received" when I tried to add an attachment.
Fixed it by adding "\r\n" to stream chunks in SmtpSocketClient.cs, at the end of SendAttachments() method:
May I ask if you have any explenation for this?
Attachment is sent as a base64-encoded string and it looks like some email servers (hMailServer in my case) have limits for string length . So basically I just split one huge line to smaller parts.
Great, would you be kind enough to do a pull request?