- Joined
- Oct 25, 2004
- Location
- 127.0.0.1
When trying to run this code in Visual C# 2005:
I get the following errors:
any ideas could do with some help ?
thanks
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Mail;
namespace Email
{
class Program
{
static void Main(string[] args)
{
string to;
string subject;
string message;
string from;
int times;
MailMessage mail;
Console.WriteLine("To, Subject, Message, from");
to = Console.ReadLine();
subject = Console.ReadLine();
message = Console.ReadLine();
from = Console.ReadLine();
mail.To = to;
mail.Subject = subject;
mail.Body = message;
SmtpClient smtp;
smtp.Host = "localhost";
smtp.Send(mail);
Console.ReadLine();
}
}
}
I get the following errors:
Code:
Error 1 Property or indexer 'System.Net.Mail.MailMessage.To' cannot be assigned to -- it is read only D:\Documents and Settings\Jason\My Documents\Visual Studio 2005\Projects\Email\Email\Program.cs 27 13 Email
Error 2 Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddressCollection' D:\Documents and Settings\Jason\My Documents\Visual Studio 2005\Projects\Email\Email\Program.cs 27 23 Email
any ideas could do with some help ?
thanks