dotnetopenmail使用介绍

            DotNetOpenMail.EmailMessage email  =   new  DotNetOpenMail.EmailMessage();
            
            email.FromAddress 
=   new  DotNetOpenMail.EmailAddress( " [email protected] " );
            
            DotNetOpenMail.EmailAddressCollection toAddresses 
=   new  DotNetOpenMail.EmailAddressCollection();
            DotNetOpenMail.EmailAddress toAddress 
=   new  DotNetOpenMail.EmailAddress( " [email protected] " );
            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 " ;

你可能感兴趣的:(使用)