- status: open --> closed
I amd trying to add an attachment to an email, When the add attachment line is read, I get an object error.
Here is the code
var mymessage = new MimeMailMessage
{
From = new MimeMailAddress(Mail),
Subject = "Web Purchase Receipt " + DateTime.Now.ToString("yyyyMMdd"),
Body = "body"
};
mymessage.To.Add("me@hotmail.com");
var mailer = new MimeMailer(Host, 465)
{
User = User,
Password = Pass,
EnableImplicitSsl = true,
AuthenticationMode = AuthenticationType.Base64
};
var a = new MimeAttachment("c:\temp\Integra POS.pdf")
{
//ContentType = new ContentType("application/pdf"),
ContentType = new ContentType("application/octet-stream"),
Location = AttachmentLocation.Inline
};
AttachList.Add(a);
foreach (Attachment t in AttachList)
{
mailer.MailMessage.Attachments.Add((MimeAttachment)t);//Error on the line
}
((SmtpSocketClient)mailer).SslType = SslMode.Ssl;
mailer.SendCompleted += SendCompleted;
mailer.SendMailAsync(mymessage);