Thread: what's wrong? how to send mail via console app?

  1. #1
    Registered User
    Join Date
    Nov 2017
    Posts
    4

    what's wrong? how to send mail via console app?

    Code:
     static void Main(string[] args)
            {
                Console.WriteLine("Mail To");
                MailAddress to = new MailAddress(Console.ReadLine());
    
    
                Console.WriteLine("Mail From");
                MailAddress from = new MailAddress(Console.ReadLine());
    
    
                MailMessage mail = new MailMessage(from, to);
    
    
                Console.WriteLine("Subject");
                mail.Subject = Console.ReadLine();
    
    
                Console.WriteLine("Your Message");
                mail.Body = Console.ReadLine();
    
    
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
    
    
                smtp.Credentials = new NetworkCredential(
                    "[email protected]", "password");
                smtp.EnableSsl = true;
                Console.WriteLine("Sending email...");
                smtp.Send(mail); //The SMTP server requires a secure connection or the client was not authenticated
            }

  2. #2
    Registered User
    Join Date
    Jun 2017
    Posts
    157
    You need to tell what's wrong. Compile errors, exceptions, crash....?

  3. #3
    Banned
    Join Date
    Aug 2017
    Posts
    861
    how does that thing even kind of work?
    google how to declare main in C
    The C Book — Arguments to main

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Quote Originally Posted by userxbw View Post
    how does that thing even kind of work?
    google how to declare main in C
    The C Book — Arguments to main
    O_o

    You need to stop being in such a hurry to post.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  5. #5
    Registered User
    Join Date
    Nov 2017
    Posts
    7
    Try this, I have seen it all over the internet.


    Simple SMTP E-Mail Sender in C#… Console application - CodeProject

  6. #6
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by phantomotap View Post
    O_o

    You need to stop being in such a hurry to post.

    Soma
    you failed to see I just asked a question and gave reference HELLO!!

    Quote Originally Posted by userxbw View Post
    how does that thing even kind of work?
    google how to declare main in C reference
    The C Book — Arguments to main
    Did you not Notice the Question Mark?
    Or even how it was phrased to make it a question, and NOT a statement
    now I have to ask,
    do you even know the difference between a question and a statement and all they entail

    furthermore the way it is presented that is still not a valid main for C or C++ . Then I just thought what does Java's look like so I just googled that and well
    public static void main(String [ ] args)
    {

    still it is not valid Java look at the Main vs main in his code, so if it is even Java then he is not even in the proper forum.
    either way I don't know why you're getting your panties in a ruffle or what is that term I seen in here assbite asshurt or something or was it buttsore ( definitely a freudian term)


    so to end this is I was just a QUESTION and not a Statement nonetheless. .


    then I just now just looked and well excuses me this is for C# don't C much of that in here so when I asked that Question not making a statement, even though I was under the impression it was for C but still nonetheless I stayed in the safe zone by asking a Question .. do you understand what a Question is?????<-- that is just a question a simple yes or no question. that is all it is.

    Main() and Command-Line Arguments (C# Programming Guide)

    The Java Main Method
    Last edited by userxbw; 11-22-2017 at 10:24 AM.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    So now you know there is C#, and perhaps to look a bit before jumping to conclusions.
    Losing your rag every time someone points out something doesn't help your cause either.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by Salem View Post
    So now you know there is C#, and perhaps to look a bit before jumping to conclusions.
    Losing your rag every time someone points out something doesn't help your cause either.
    it was still a question no matter what ! so that jumping to conclusions does not even apply ... how can a question mis lead you

    well may you it can..because my question did mislead you

    other wise you'd not have said anything. ,.
    ot maybe you just got an issue with people asking questions in here I doono you need help.
    it is only a question he is the one that jumped to a conclusion not I
    loosing my rag none sense its called setting him straight and being honest. something you see as a fault I suppose.
    Last edited by userxbw; 11-22-2017 at 05:28 PM.

  9. #9
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    I'm just being straight-forward and honest with you, but #3 just comes across as you thinking you were on the C board. Because C links are not relevant and misleading on the C# board.

    You asking "how does that even work?" There are two ways, that I can think of, that you mean this question. First, you could have asked it out of a genuine desire to know how that works, for yourself. If you did, the C reference page would not help you understand C# programs. It makes it look like you aren't even aware that it is a C# program. Second, you could have asked how it works in the same way someone might ask "how does that even compile?" with the connotation that the code is so bad that compiling as "C" would show many issues with the code. With this interpretation, it is a stupid question, because the code looks compilable to begin with, but also because if you were simply confused by the syntax yourself, you look like you don't know where you are. The C# board.

    Therefore, you shouldn't be surprised when people suggest that you slow down next time, and realize that you are on the C# board before replying.

    If you did mean the first interpretation, then sorry. You might get an answer eventually, but not by spitting like a viper at everyone like in #6.
    Last edited by whiteflags; 11-24-2017 at 02:17 AM.

  10. #10
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    I'm just being straight-forward and honest with you, but #3 just comes across as you thinking you were on the C board. Because C links are not relevant and misleading on the C# board.

    You asking "how does that even work?" There are two ways, that I can think of, that you mean this question. First, you could have asked it out of a genuine desire to know how that works, for yourself. If you did, the C reference page would not help you understand C# programs. It makes it look like you aren't even aware that it is a C# program. Second, you could have asked how it works in the same way someone might ask "how does that even compile?" with the connotation that the code is so bad that compiling as "C" would show many issues with the code. With this interpretation, it is a stupid question, because the code looks compilable to begin with, but also because if you were simply confused by the syntax yourself, you look like you don't know where you are. The C# board.

    Therefore, you shouldn't be surprised when people suggest that you slow down next time, and realize that you are on the C# board before replying.

    If you did mean the first interpretation, then sorry. You might get an answer eventually, but not by spitting like a viper at everyone like in #6.
    cannot anyone see that it is just a harmless question regardless .. I have no idea what is wrong with this world anymore, am I dealing with a bunch of anal retentive people here?

  11. #11
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Well, you're blind to the fact that asking questions in the wrong place and time can make you look like a sarcastic ...............

  12. #12
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by whiteflags View Post
    Well, you're blind to the fact that asking questions in the wrong place and time can make you look like a sarcastic ...............
    so you're all just looking like anal retentive people and I'm just being sarcastic?

  13. #13
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    I confess; I don't think "google how to declare main in C" is a question.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  14. #14
    Banned
    Join Date
    Aug 2017
    Posts
    861
    Quote Originally Posted by phantomotap View Post
    O_o

    I confess; I don't think "google how to declare main in C" is a question.

    Soma
    have you learned about references yet?

    ask question gives reference to what one is thinking bout to give a perspective or this is what is in my brain. to the OP not anyone but the OP .. have not seen him making any qualms on it. nevertheless,

    a looker on sees then takes in and analyzes, or just jumps to conclusion then gives advice to not be in a hurry to post.

    how long does one have to wait before asking question? is their a law or an international law even on the waiting period before asking a question.? are their forms involved in this? Do you and others think this stupid line of conversion over a question has gone long enough or is it just me?
    Last edited by userxbw; 11-24-2017 at 06:15 PM.

  15. #15
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Stick a fork in it, it's done.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do I send mail ?
    By gilit2 in forum C Programming
    Replies: 6
    Last Post: 01-26-2012, 03:42 AM
  2. Please someone, how do you send an e-mail in c++?
    By RobertK in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2003, 06:32 AM
  3. how to send e-mail
    By metamp in forum Windows Programming
    Replies: 7
    Last Post: 02-17-2002, 05:24 AM

Tags for this Thread