//设置统一回复地址
if (!string.IsNullOrEmpty(replyEmail) && ValidateUtil.IsEmail(replyEmail))
{
mainEntity.ReplyTo = new AddressList();
mainEntity.ReplyTo.Add(new MailboxAddress(replyEmail, replyEmail));
}
MimeEntity textEntity = mainEntity.ChildEntities.Add();
textEntity.ContentType = MediaType_enum.Text_html;
textEntity.ContentTransferEncoding = ContentTransferEncoding_enum.QuotedPrintable;
textEntity.DataText = body;
//附件
foreach (string attach in attachments)
{
MimeEntity attachmentEntity = mainEntity.ChildEntities.Add();
attachmentEntity.ContentType = MediaType_enum.Application_octet_stream;
attachmentEntity.ContentDisposition = ContentDisposition_enum.Attachment;
attachmentEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
FileInfo file = new FileInfo(attach);
attachmentEntity.ContentDisposition_FileName = file.Name;
attachmentEntity.DataFromFile(attach);
}
//嵌入图片
foreach (string key in embedImages.Keys)
{
MimeEntity attachmentEntity = mainEntity.ChildEntities.Add();
attachmentEntity.ContentType = MediaType_enum.Application_octet_stream;
attachmentEntity.ContentDisposition = ContentDisposition_enum.Inline;
attachmentEntity.ContentTransferEncoding = ContentTransferEncoding_enum.Base64;
string imageFile = embedImages[key];
FileInfo file = new FileInfo(imageFile);
attachmentEntity.ContentDisposition_FileName = file.Name;
//string displayName = Path.GetFileNameWithoutExtension(fileName);
attachmentEntity.ContentID = key;//BytesTools.BytesToHex(Encoding.Default.GetBytes(fileName));
attachmentEntity.DataFromFile(imageFile);
}
return m;
}
综合以上两者的发送功能,都可以实现邮件的发送操作,如下界面是发送邮件界面。
3、LumiSoft.NET存储eml邮件文件以及发送eml文件操作
除了上面的发送普通邮件,Lumisoft还支持吧邮件序列号存储到文件(.eml邮件文件)里面,然后也可以通过把文件读取到流里面,进行发送,对于某种场合,可以把邮件存储到eml文件是一个很好的操作。
存储EML文件的相关操作如下所示。
复制代码 代码如下: