Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6530775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:47:47+00:00 2026-05-25T09:47:47+00:00

ok, im having some syntax issues that keep evading me. :( one is at

  • 0

ok, im having some syntax issues that keep evading me. 🙁

one is at the very end with Type or namespace definition, or end-of-file expected

and the other is about half way at private static void OnTimedEvent1(object source, ElapsedEventArgs e) with { expected

thanks

and the actual CODE: ( i put where the errors are in here too)

namespace Gmail_final_prep
{
    public class Gmail_FP
    {
        private static System.Timers.Timer gTimer;

        public static void GMain()
        {
            gTimer = new System.Timers.Timer(2000);

            // Hook up the Elapsed event for the timer.
            gTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent1);

            gTimer.Interval = 2000;
            gTimer.Enabled = true;

            Console.WriteLine("Press the Enter key to exit the program.");
            Console.ReadLine();

            // If the timer is declared in a long-running method, use
            // KeepAlive to prevent garbage collection from occurring
            // before the method ends.
            //GC.KeepAlive(gTimer);
        }

        private static void OnTimedEvent1(object source, ElapsedEventArgs e)
        { // { expected here
            public static string TextToBase64(string sAscii)
            {
                System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                byte[] bytes = encoding.GetBytes(sAscii);
                return System.Convert.ToBase64String(bytes, 0, bytes.Length);
            }

            public static string CheckMail()
            {
                string result = "0";

                try
                {
                    var url = @"https://gmail.google.com/gmail/feed/atom";
                    var USER = "usr";
                    var PASS = "pss";

                    var encoded = TextToBase64(USER + ":" + PASS);

                    var myWebRequest = HttpWebRequest.Create(url);
                    myWebRequest.Method = "POST";
                    myWebRequest.ContentLength = 0;
                    myWebRequest.Headers.Add("Authorization", "Basic " + encoded);

                    var response = myWebRequest.GetResponse();
                    var stream = response.GetResponseStream();

                    XmlReader reader = XmlReader.Create(stream);
                    System.Text.StringBuilder gml = new System.Text.StringBuilder();
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                            if (reader.Name == "fullcount")
                            {
                                gml.Append(reader.ReadElementContentAsString()).Append(",");
                                //result = reader.ReadElementContentAsString();
                                //return result;
                            }
                    }
                    Console.WriteLine(gml.ToString());
                }
                catch (Exception ee) { Console.WriteLine(ee.Message); }
                return result;
            }
        }       
    }
} // Type or namespace definition, or end-of-file expected here
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:47:48+00:00Added an answer on May 25, 2026 at 9:47 am

    You have a method within another method.

        private static void OnTimedEvent1(object source, ElapsedEventArgs e) 
        { // { expected here 
            public static string TextToBase64(string sAscii)
    

    This may be what you’re trying to do — you want to call CheckMail() from within your event handler.

    using System;
    using System.Net;
    using System.Timers;
    using System.Xml;
    
    namespace Gmail_final_prep 
    { 
    public class Gmail_FP 
    { 
        private static System.Timers.Timer gTimer; 
    
        public static void GMain() 
        { 
            gTimer = new System.Timers.Timer(2000); 
    
            // Hook up the Elapsed event for the timer. 
            gTimer.Elapsed += OnTimedEvent1; 
    
            gTimer.Interval = 2000; 
            gTimer.Enabled = true; 
    
            Console.WriteLine("Press the Enter key to exit the program."); 
            Console.ReadLine(); 
    
            // If the timer is declared in a long-running method, use 
            // KeepAlive to prevent garbage collection from occurring 
            // before the method ends. 
            //GC.KeepAlive(gTimer); 
        } 
    
        private static void OnTimedEvent1(object source, ElapsedEventArgs e) 
        { // { expected here 
            CheckMail();
        }
    
        public static string TextToBase64(string sAscii)
        {
            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
            byte[] bytes = encoding.GetBytes(sAscii);
            return System.Convert.ToBase64String(bytes, 0, bytes.Length);
        }
    
        public static string CheckMail()
        {
            string result = "0";
    
            try
            {
                var url = @"https://gmail.google.com/gmail/feed/atom";
                var USER = "usr";
                var PASS = "pss";
    
                var encoded = TextToBase64(USER + ":" + PASS);
    
                var myWebRequest = HttpWebRequest.Create(url);
                myWebRequest.Method = "POST";
                myWebRequest.ContentLength = 0;
                myWebRequest.Headers.Add("Authorization", "Basic " + encoded);
    
                var response = myWebRequest.GetResponse();
                var stream = response.GetResponseStream();
    
                XmlReader reader = XmlReader.Create(stream);
                System.Text.StringBuilder gml = new System.Text.StringBuilder();
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                        if (reader.Name == "fullcount")
                        {
                            gml.Append(reader.ReadElementContentAsString()).Append(",");
                            //result = reader.ReadElementContentAsString(); 
                            //return result; 
                        }
                }
                Console.WriteLine(gml.ToString());
            }
            catch (Exception ee) { Console.WriteLine(ee.Message); }
            return result;
        } 
    } 
    } // Type or namespace definition, or end-of-file expected here 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues with a bit of LINQ syntax and I believe I'm
I am having some issues with full view caching in cakephp. The url that
I was having some trouble grokking the list comprehension syntax in Python, so I
Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and
Having some issues with the ... in ObjectiveC. I'm basically wrapping a method and
Having some trouble with what should be a very simple scenario. For example purposes,
I've written a pretty simple recursive-descent parser in Java, but having some issues with
I'm having some problem with my SQL syntax/escaping variables on my LAMP server. The
I'm having some serious issues using Zend_Lucene and foreign characters like åäö. These issues
Im reading c++ primer plus and having some issues understanding how implicit instantiation works.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.