我做的网站 需要一个邮件的发送功能,功能如下:  用户之间可以通过网站发送邮件,发送方和接受方不限制邮箱类型,比如我用[email protected] 发送给 [email protected] 怎么发送啊~~~最好有代码~~~谢谢了~~

解决方案 »

  1.   


    MailAddress from = new MailAddress("[email protected]", "Ben Miller");
        MailAddress to = new MailAddress("[email protected]", "Jane Clayton");
        MailMessage message = new MailMessage(from, to);
        // message.Subject = "Using the SmtpClient class.";
        message.Subject = "Using the SmtpClient class.";
        message.Body = @"Using this feature, you can send an e-mail message from an application very easily.";
        // Add a carbon copy recipient.
        MailAddress copy = new MailAddress("[email protected]");
        message.CC.Add(copy);
        SmtpClient client = new SmtpClient(server);
        // Include credentials if the server requires them.
        client.Credentials = CredentialCache.DefaultNetworkCredentials;
        Console.WriteLine("Sending an e-mail message to {0} by using the SMTP host {1}.",
             to.Address, client.Host);
        client.Send(message);
      

  2.   

    1  参考 1 
    2 也可以使用CDO组件
      

  3.   

    LS  你这句SmtpClient client = new SmtpClient(server);里面的server是怎么来的? 这个转发不需要账号密码就可以了?
      

  4.   

    所有邮件都使用代理发送,只要输入对方的email地址,使用自定义的邮箱发送。
    比如gmail邮箱/// <summary>
        /// 使用Gmail邮箱发送邮件
        /// </summary>
        /// <param name="From">指定发送者的Gmail邮箱</param>
        /// <param name="Password">邮箱的密码</param>
        /// <param name="To">收件人的地址,多个用户用分号分割</param>
        /// <param name="Cc">抄送人的地址,多个用户用分号分割</param>
        /// <param name="Bcc">密送者的地址,多个用户用分号分割</param>
        /// <param name="Subject">邮件的主题</param>
        /// <param name="Body">邮件的内容</param>
        /// <returns>返回发送结果</returns>
        public static string sendMail(string From, string Password, string To, string Cc, string Bcc, string Subject, string Body)
        {
            // Mail initialization
            MailMessage mailMsg = new MailMessage();
            mailMsg.From = From;
            mailMsg.To = To;
            mailMsg.Cc = Cc;
            mailMsg.Bcc = Bcc;
            mailMsg.Subject = Subject;
            mailMsg.BodyFormat = MailFormat.Html;
            mailMsg.Body = Body;
            mailMsg.Priority = MailPriority.High;
            // Smtp configuration
            SmtpMail.SmtpServer = "smtp.gmail.com";
            // - smtp.gmail.com use smtp authentication
            mailMsg.Fields.Add
                ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
                From);
            mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
                Password);
            // - smtp.gmail.com use port 465 or 587
            mailMsg.Fields.Add
                ("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
            // - smtp.gmail.com use STARTTLS (some call this SSL)
            mailMsg.Fields.Add
                ("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
            // try to send Mail
            try
            {
                SmtpMail.Send(mailMsg);
                return "信息发送成功,请耐心等待回复";
            }
            catch (Exception ex)
            {
                return "发送错误:以下是错误信息:<br>" + ex.Message;
            }
        }:
      

  5.   

    public static bool EmailSend(string strFrom, string strTo, string title ,string strContent, string strUser, string strPassword, string strSmtpServer)
        {
            bool strSucess = true;    
            System.Net.Mail.SmtpClient cln = new System.Net.Mail.SmtpClient(strSmtpServer);
            cln.UseDefaultCredentials = false;
            cln.Credentials = new System.Net.NetworkCredential(strUser, strPassword);//验证身份
            cln.DeliveryMethod = SmtpDeliveryMethod.Network;//指定邮件通过smtp服务器发送
            MailMessage mes = new MailMessage(strFrom,strTo,title,strContent);//邮件内容
            mes.SubjectEncoding = Encoding.GetEncoding("GB2312");
            mes.BodyEncoding = Encoding.GetEncoding("GB2312");
            mes.IsBodyHtml = true;
            try
            {
                cln.Send(mes);
            }
            catch (Exception ee)
            {
                strSucess = false;
            }
            return strSucess;
        }  
      

  6.   


    你这种法邮件的方法 最后用户接受到的效果是不是这样啊?
    比如[email protected] 通过网站发送给 [email protected] 最后的效果是不是这样"邮件发送人:[email protected]; 接收人:[email protected];内容:....."  
      

  7.   

    最主要的是 网易的邮箱SMTP和POP 在06年就关闭了  如果是新网易邮箱的话是不能作为发送邮箱
      

  8.   


    我使用GMAIL 可以不~~~~ 我想要这种效果  比如[email protected] 通过网站发送给 [email protected] 最后的效果要这样"邮件发送人:[email protected]; 接收人:[email protected];内容:....."  
      

  9.   

    呵呵 你是想要格式是吧   message.IsBodyHtml = true;然后把内容用HTML格式写出来就是了