现在已经能正常的发送送件和附件,现在要加入cc 和BCC
没做过,请指点一下.
MailMessage mail = new MailMessage();        string pwd,s_address, r_address;
                //收邮件地址
        r_address = mailto.Text.Trim();
        mail.To = r_address;        //发邮件地址
        s_address = mailfrom.Text.Trim();
        mail.From = s_address;        int i = s_address.IndexOf('@');
        string server = s_address.Substring(i+1, (s_address.Length-i-1));        //主题
        mail.Subject = subject.Text;        //内容
        mail.Body = mailbody.Text;        //密码
        pwd = psd.Text;
                try
        {
            mail.Fields.Add(@"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            mail.Fields.Add(@"http://schemas.microsoft.com/cdo/configuration/sendusername", s_address);
            mail.Fields.Add(@"http://schemas.microsoft.com/cdo/configuration/sendpassword", pwd);            SmtpMail.SmtpServer = "smtp." + server;
            SmtpMail.Send(mail);
            Headingmsg.Text = "Successfully sended!";        }
        catch(Exception ex)
        {
            Headingmsg.Text = "Error:" + ex.Message;
        }

解决方案 »

  1.   

    jmal   是VB的吧
    我们要用C#做
      

  2.   

    CC:
    public static void CreateCopyMessage(string server)
    {
        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);
    }BCC:
    public static void CreateBccTestMessage(string server)
    {
        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.Body = @"Using this feature, you can send an e-mail message from an application very easily.";
        MailAddress bcc = new MailAddress("[email protected]");
        message.Bcc.Add(bcc);
        SmtpClient client = new SmtpClient(server);
        client.Credentials = CredentialCache.DefaultNetworkCredentials;
        Console.WriteLine("Sending an e-mail message to {0} and {1}.", to.DisplayName, message.Bcc.ToString());
        client.Send(message);
    }