调用示例:

基于SOCKET Send mail:
 1EmailSender ms = new EmailSender(EmailSender.SendClassType.SocketSend);
 2            ms.UserId =@"帐号";  
 3            ms.PassWord  = "密码"
 4            ms.Server = "服务器";
 5
 6            EmailInfo mail=new EmailInfo();
 7            mail.From =" ";
 8            mail.To   = " ";        
 9            mail.CC  ="";            
10             
11            mail.Subject  = "Web Test Email No."+ iNum.ToString() ;
12            mail.HtmlBody   = @"阿斗撒<b>HELLO</b>asdfa</a><font color=red>this is red </font>" ;
13            mail.IsHtml =true;
14            mail.Priority =1;
15            mail.LanguageEncoding="GB2312";
16            mail.Attachments.Add (new EmailSender.AttachmentInfo (Server.MapPath(@"test.txt")));
17             
18            try
19            {
20                if(ms.SendEmail(mail))
21                {
22                    Response.Write ("mail sended successfully!");
23                }

24                else
25                {
26                    Response.Write ("mail failure.");
27                }

28            }

29            catch  
30            {
31                Response.Write  ("ERROR" );
32            }

基于WebMail:
EmailSender ms = new EmailSender();
            ms.UserId 
=@"帐号";  
            ms.PassWord  
= "密码"
            ms.Server 
= "服务器";

            EmailInfo mail
=new EmailInfo();
            mail.From 
=" ";
            mail.To   
= " ";        
            mail.CC 
=" ";
 
            mail.Subject  
= "Web Test Email No."+ iNum.ToString() ;
            mail.Body   
= @"hhh阿斗撒<b>HELLO</b>asdfa</a><font color=red>this is red </font>" ;
            mail.IsHtml 
=true;
            mail.Priority 
=1;
            mail.LanguageEncoding
="GB2312";

            mail.Attachments.Add (Server.MapPath(
@"test.txt"));

             
            
try
            
{
                
if(ms.SendEmail(mail))
                
{
                    Response.Write (
"mail sended successfully!");
                }

                
else
                
{
                    Response.Write (
"mail failure.");
                }

            }

            
catch  
            
{
                Response.Write  (
"ERROR" );
            }

                
        }
posted on 2006-01-14 09:38  Jin  阅读(496)  评论(1编辑  收藏  举报