网站公告列表

  没有公告

加入收藏
设为首页
在线投稿

您现在的位置: IT知识网 >> IT知识 >> 维修维护 >> 其它外设维护维修 >> 文章正文

 

  EMAIL发送系统(C#+基于SMTP认证)[转]           

EMAIL发送系统(C#+基于SMTP认证)[转]
作者:佚名 文章来源:不详 点击数: 更新时间:2006-12-6 1:06:56

    return false;
    SendBufferstr="DATA" + ENTER;
    if(!Dialog(SendBufferstr,_NetworkStream))
    return false;
    
    SendBufferstrBuilder.Append("From:" + fromName + "<" + from +">" +ENTER);
    
    SendBufferstrBuilder.Append("To:=?"+Charset.ToUpper()+"?B?"+Base64Encode(recipientName)+"?="+"<"+recipients[0]+">"+ENTER);
    
    SendBufferstrBuilder.Append("CC:");
    for(int i=0;i    {
    SendBufferstrBuilder.Append(recipients[i].ToString() + "<" + recipients[i].ToString() +">,");
    }
    SendBufferstrBuilder.Append(ENTER);
    
    SendBufferstrBuilder.Append(((subject==String.Empty || subject==null)?"Subject:":((Charset=="")?("Subject:" + subject):("Subject:" + "=?" + Charset.ToUpper() + "?B?" + Base64Encode(subject) +"?="))) + ENTER);
    SendBufferstrBuilder.Append("X-Priority:" + priority + ENTER);
    SendBufferstrBuilder.Append("X-MSMail-Priority:" + priority + ENTER);
    SendBufferstrBuilder.Append("Importance:" + priority + ENTER);
    SendBufferstrBuilder.Append("X-Mailer: Lion.Web.Mail.SmtpMail Pubclass [cn]" + ENTER);
    SendBufferstrBuilder.Append("MIME-Version: 1.0" + ENTER);
    
    if(attachments != null && attachments.Count!=0)
    {
    SendBufferstrBuilder.Append("Content-Type: multipart/mixed;" + ENTER);
    SendBufferstrBuilder.Append(" boundary=\"====="+(isHtml?"001_Dragon520636771063_":"001_Dragon303406132050_")+"=====\""+ENTER+ENTER);
    }
    
    if(isHtml)
    {
    if(attachments != null && attachments.Count==0)
    {
    SendBufferstrBuilder.Append("Content-Type: multipart/alternative;"+ENTER);//内容格式和分隔符
    SendBufferstrBuilder.Append(" boundary=\"=====003_Dragon520636771063_=====\""+ENTER+ENTER);
    
    SendBufferstrBuilder.Append("This is a multi-part message in MIME format."+ENTER+ENTER);
    }
    else
    {
    SendBufferstrBuilder.Append("This is a multi-part message in MIME format."+ENTER+ENTER);
    SendBufferstrBuilder.Append("--=====001_Dragon520636771063_====="+ENTER);
    SendBufferstrBuilder.Append("Content-Type: multipart/alternative;"+ENTER);//内容格式和分隔符
    SendBufferstrBuilder.Append(" boundary=\"=====003_Dragon520636771063_=====\""+ENTER+ENTER);
    }
    SendBufferstrBuilder.Append("--=====003_Dragon520636771063_====="+ENTER);
    SendBufferstrBuilder.Append("Content-Type: text/plain;"+ ENTER);
    SendBufferstrBuilder.Append(((Charset=="")?(" charset=\"iso-8859-1\""):(" charset=\"" + Charset.ToLower() + "\"")) + ENTER);
    SendBufferstrBuilder.Append("Content-Transfer-Encoding: base64" + ENTER + ENTER);
    SendBufferstrBuilder.Append(Base64Encode("邮件内容为HTML格式,请选择HTML方式查看") + ENTER + ENTER);
    
    SendBufferstrBuilder.Append("--=====003_Dragon520636771063_====="+ENTER);
    
    
    
    SendBufferstrBuilder.Append("Content-Type: text/html;" + ENTER);
    SendBufferstrBuilder.Append(((Charset=="")?(" charset=\"iso-8859-1\""):(" charset=\"" + Charset.ToLower() + "\"")) + ENTER);
    SendBufferstrBuilder.Append("Content-Transfer-Encoding: base64" + ENTER + ENTER);
    SendBufferstrBuilder.Append(Base64Encode(body) + ENTER + ENTER);
    SendBufferstrBuilder.Append("--=====003_Dragon520636771063_=====--"+ENTER);
    }
    else
    {
    if(attachments != null && attachments.Count!=0)
    {
    SendBufferstrBuilder.Append("--=====001_Dragon303406132050_====="+ENTER);
    }
    SendBufferstrBuilder.Append("Content-Type: text/plain;" + ENTER);
    SendBufferstrBuilder.Append(((Charset=="")?(" charset=\"iso-8859-1\""):(" charset=\"" + Charset.ToLower() + "\"")) + ENTER);
    SendBufferstrBuilder.Append("Content-Transfer-Encoding: base64" + ENTER + ENTER);
    SendBufferstrBuilder.Append(Base64Encode(body) + ENTER);
    }
    
    //SendBufferstr += "Content-Transfer-Encoding: base64"+ENTER;
    if(attachments != null && attachments.Count!=0)
    {
    for(int i=0;i    {
    string filepath = (string)attachments[i];
    SendBufferstrBuilder.Append("--====="+ (isHtml?"001_Dragon520636771063_":"001_Dragon303406132050_") +"====="+ENTER);
    //SendBufferstr += "Content-Type: application/octet-stream"+ENTER;
    SendBufferstrBuilder.Append("Content-Type: text/plain;"+ENTER);
    SendBufferstrBuilder.Append(" name=\"=?"+Charset.ToUpper()+"?B?"+Base64Encode(filepath.Substring(filepath.LastIndexOf("\\")+1))+"?=\""+ENTER);
    SendBufferstrBuilder.Append("Content-Transfer-Encoding: base64"+ENTER);
    SendBufferstrBuilder.Append("Content-Disposition: attachment;"+ENTER);
    SendBufferstrBuilder.Append(" filename=\"=?"+Charset.ToUpper()+"?B?"+Base64Encode(filepath.Substring(filepath.LastIndexOf("\\")+1))+"?=\""+ENTER+ENTER);
    SendBufferstrBuilder.Append(GetStream(filepath)+ENTER+ENTER);
    }
    SendBufferstrBuilder.Append("--====="+ (isHtml?"001_Dragon520636771063_":"001_Dragon303406132050_") +"=====--"+ENTER+ENTER);
    }
    SendBufferstrBuilder.Append(ENTER + "." + ENTER);
    SendBufferstr = SendBufferstrBuilder.ToString();
    
    if(!Dialog(SendBufferstr,_NetworkStream))
    return false;
    
    
    SendBufferstr="QUIT" + ENTER;
    if(!Dialog(SendBufferstr,_NetworkStream))
    return false;
    
    return true;
    }
    
    #endregion
    
    #region
    /*
    ///
    /// 添加一个密件收件人
    ///

    /// 收件人地址
    public bool AddRecipientBCC(string str)
    {
    if(str==null||str.Trim()=="")
    return true;
    if(RecipientBCCNum<10)
    {
    RecipientBCC.Add(RecipientBCCNum,str);
    RecipientBCCNum++;
    return true;
    }
    else
    {
    m_logs.Append("错误:收件人过多");
    return false;
    }
    }
    
    
    ///
    /// 添加一组密件收件人(不超过10个),参数为字符串数组
    ///

    /// 保存有收件人地址的字符串数组(不超过10个)
    public bool AddRecipientBCC(string[] str)
    {
    for(int i=0;i    {
    if(!AddRecipientBCC(str[i]))
    {
    return false;
    }
    }
    return true;
    }
    
    */
    #endregion
    }
    
    ///
    /// 邮件发送优先级
    ///

    public enum Priority
    {
    High,
    Normal,
    Low
    }
    
  &nb

上一页  [1] [2] [3] [4] [5] 下一页

文章录入:wuyongjian    责任编辑:wuyongjian 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最 新 热 门
    相 关 文 章
    NBMA环境下OSPF配置需要
    OSPFv3动态路由协议在NB
    use a route-map to lim
    Cisco 3Com Avaya 华为等
    Cisco 3Com Avaya 华为等
    配置Cisco交换机端□和M
    CiscoAironet天线和附件
    用Route Map实现多ISP I
    xmodem升级IOS的详细步骤
    利用Xmodem 升级2610 IO
     
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    Copyright© ITZS.NET All Rights Reserved
    QQ:272895858   ICP备案编号:吉ICP备07000044号
    IT知识网 站长:博浪