DotNetOpenMail.EmailMessage email
=
new
DotNetOpenMail.EmailMessage();
email.FromAddress = new DotNetOpenMail.EmailAddress( " zhifengwu1211@126.com " );
DotNetOpenMail.EmailAddressCollection toAddresses = new DotNetOpenMail.EmailAddressCollection();
DotNetOpenMail.EmailAddress toAddress = new DotNetOpenMail.EmailAddress( " zhifengwu1211@126.com " );
toAddresses.Add(toAddress);
email.ToAddresses.Add(toAddress);
email.Subject = " this is test " ;
DotNetOpenMail.SmtpServer smtpserver = new DotNetOpenMail.SmtpServer( " 192.168.2.129 " );
StreamReader readfile = new StreamReader( " d:\\mycert.cer " );
Byte[] fileBytes = System.Text.Encoding.Default.GetBytes(readfile.ReadToEnd());
DotNetOpenMail.FileAttachment fileAttachment = new DotNetOpenMail.FileAttachment(fileBytes);
fileAttachment.FileName = " mycert.cer " ;
email.AddMixedAttachment(fileAttachment);
bool result = email.Send(smtpserver);
if (result == true )
this .label1.Text = " success " ;
else
this .label1.Text = " error " ;
email.FromAddress = new DotNetOpenMail.EmailAddress( " zhifengwu1211@126.com " );
DotNetOpenMail.EmailAddressCollection toAddresses = new DotNetOpenMail.EmailAddressCollection();
DotNetOpenMail.EmailAddress toAddress = new DotNetOpenMail.EmailAddress( " zhifengwu1211@126.com " );
toAddresses.Add(toAddress);
email.ToAddresses.Add(toAddress);
email.Subject = " this is test " ;
DotNetOpenMail.SmtpServer smtpserver = new DotNetOpenMail.SmtpServer( " 192.168.2.129 " );
StreamReader readfile = new StreamReader( " d:\\mycert.cer " );
Byte[] fileBytes = System.Text.Encoding.Default.GetBytes(readfile.ReadToEnd());
DotNetOpenMail.FileAttachment fileAttachment = new DotNetOpenMail.FileAttachment(fileBytes);
fileAttachment.FileName = " mycert.cer " ;
email.AddMixedAttachment(fileAttachment);
bool result = email.Send(smtpserver);
if (result == true )
this .label1.Text = " success " ;
else
this .label1.Text = " error " ;