Here is my issue. I'm attempting to create a daily mailing using a console app. Well, when I started, I for some brilliant reason made a web app. So I'm trying to translate it into a console app, and while I THINK this should work, I keep getting a "type or namespace definition, or end-of-file expected" immediately following my static Main. It looks to me as if I have all of my brackets accounted for, but it's not reading it for some reason. It's a pretty simple app, but I'm also pretty new at this.
Can anybody:
A. Explain why I'm getting this error and/or tell me how to fix it;
B. Point out anything blatant that I might be missing?
I'd really appreciate any help anyone can give me.
using System;
using System.IO;
using System.Net;
using System.Net.Mail;
using System.Web.UI;
namespace Daily_Mailing
{
class Program
{
static void Main(string[] args)
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
try
{
MailAddress fromAddress = new MailAddress("Admin@mywebsite.com", "Admin");
message.From = fromAddress;
message.To.Add("ME@mywebsite.com");
message.Subject = "Test";
message.CC.Add("ME@mywebsite.com");
string html = ScreenScrapeHtml("sourcewebsite.aspx");
message.Body = html;
message.IsBodyHtml = true;
smtpClient.Send(message);
}
catch (Exception)
{
}
}
public static string ScreenScrapeHtml(string url)
{
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
StreamReader sr = new StreamReader(objRequest.GetResponse().GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
return result;
}
}
}
}
}
}
Also, I might have needed to put this in the C# forum, so I can move this if needed.