MailMessage实例化以后,里面的to应该写"[email protected]"这样的字符串,
而From这个属性我应该填写什么呢?我是在本机上编写的一个web应用程序,这个属性我应该怎么填写?

解决方案 »

  1.   

    MailMessage.To 属性 
    注意:此属性在 .NET Framework 2.0 版中是新增的。 获取包含此电子邮件的收件人的地址集合。 命名空间:System.Net.Mail
    程序集:System(在 system.dll 中)public MailAddressCollection To { get; }
    public static void CreateTestMessage4(string server)
    {
        MailAddress from = new MailAddress("[email protected]");
        MailAddress to = new MailAddress("[email protected]");
        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.";
        SmtpClient client = new SmtpClient(server);
        Console.WriteLine("Sending an e-mail message to {0} by using SMTP host {1} port {2}.",
             to.ToString(), client.Host, client.Port);
        client.Send(message);
    }
      

  2.   

    说明一下我使用的还是Framework 1.1 开发环境还是vs.net 2003现在我大概明白from也是填写字符串,但是我不明白的是为什么一定要填写我注册的邮箱,我自己本机难道没有特定的标识吗?如果
    MailObject.to = "[email protected]";
    MailObject.from = "";<--这个里面如果填写我在163的信箱,那好象是一种代理啊??