////// 调用lumisoft发送邮件 /// /// 发送者的邮件地址 /// 给谁发的邮件地址 /// 主题 /// 正文 /// 附件路径 ///成功与否 public bool SendMailByLumisoft(string fromEmailAddr, string toEmailAddr, string subjectText, string bodyText, string filePath) { Mime m = new Mime(); MimeEntity mainEntity = m.MainEntity; // Force to create From: header field mainEntity.From = new AddressList(); mainEntity.From.Add(new MailboxAddress(fromEmailAddr, fromEmailAddr)); // Force to create To: header field mainEntity.To = new AddressList(); mainEntity.To.Add(new MailboxAddress(toEmailAddr, toEmailAddr)); mainEntity.Subject = subjectText; //添加正文 mainEntity.ContentType = MediaType_enum.Multipart_mixed; MimeEntity textEntity = mainEntity.ChildEntities.Add(); textEntity.ContentType = MediaType_enum.Text_html; textEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64; textEntity.DataText = bodyText; //发送附件 if (!string.IsNullOrEmpty(filePath)) { MimeEntity attachmentEntity = new MimeEntity(); attachmentEntity.ContentType = MediaType_enum.Application_octet_stream; attachmentEntity.ContentDisposition = ContentDisposition_enum.Attachment; attachmentEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64; attachmentEntity.ContentDisposition_FileName = filePath; attachmentEntity.DataFromFile(filePath); mainEntity.ChildEntities.Add(attachmentEntity); } try { SMTP_Client.QuickSend(m); return true; } catch (Exception e) { Console.Write(e.StackTrace); return false; } }