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;
                }
 
             }
        }
 
    }
 
}
}

Visual Studio is telling me that the error is on Line 13, it tells me that that Main needs a closing }. So I tore the whole thing apart in hopes that I just misplaced the }, and pasted each part in piece by piece, and all the brackets did line up, but it still returned that particular error.

You did have an extra bracket, but you also had a class and functions dropped within your main method where you had copied/pasted the web code.

Here is a fixed format you can continue to work on (not guaranteed to work as is, I only fixed your formatting issues).

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)
        {
            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;
        }
    }
}

I think you cannot define a class in Main, so define it outside of it.
EDIT: apegram just passed 2 secs before me, but I can live with that...

You can tell I'm pretty new at this. I appreciate the input.

I think I've fixed it up to the point where I just need to re-specify my SMTP credentials that were in the Web.config file when I had it as a web app.

Thank you folks