LazerKittenz's Profile User Rating: -----

Reputation: 10 Tradesman
Group:
Contributors
Active Posts:
32 (0.02 per day)
Joined:
29-December 10
Profile Views:
2,938
Last Active:
User is offline Feb 26 2015 12:15 AM
Currently:
Offline

Previous Fields

Dream Kudos:
100
Icon   LazerKittenz has not set their status

Posts I've Made

  1. In Topic: SMTP Interfacing Application Various Problems

    Posted 26 Feb 2015

    Hey, just thought I'd return and give a bit of an update.

    The code now runs properly, but the menu still does not loop correctly. My cousin said she would ask her professor about it and figure it out on her own, but I was interested in knowing the reason behind this.

    Updated Program.cs:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace GmailClient
    {
        class Program
        {
            static String emailAddress = "";
            static String emailPassword = "";
            static int selection = 0;
            static bool isLoggedIn;
            static bool userWantsToExit;
            static String[] checkedEmails;
    
            static void Main(string[] args)
            {
                Console.Title = "G-Mail Interface Client";
                while (!userWantsToExit)
                {
                    loggedIn();
                    showMenu();
                    if (showMenu() == 1)
                    {
                        enterEmail();
                    }
                    else if (showMenu() == 2)
                    {
                        userWantsToExit = true;
                    }
                    else if (showMenu() == 3)
                    {
                        checkMail();
                    }
                    else if (showMenu() == 4)
                    {
    
                    }
                    else
                    {
                        Console.WriteLine("Invalid selection");
                    }
                }
    
            }
    
            static void checkMail()
            {
                if (isLoggedIn == true)
                {
                    checkedEmails = Gmail.getMail(emailAddress, emailPassword);
                    foreach (string email in checkedEmails)
                    {
                        Console.WriteLine(email);
                    }
                }
                else
                {
                    Console.WriteLine("Please log-in!");
                }
            }
    
            static void sendMail()
            {
                String emailSubject;
                String emailBody;
                String emailRecipient;
                if (isLoggedIn == true)
                {
    
                    Console.Write("Enter recipient's e-mail: ");
                    emailRecipient = Console.ReadLine();
                    Console.Write("Enter e-mail of subject: ");
                    emailSubject = Console.ReadLine();
                    Console.WriteLine("Enter body of e-mail: ");
                    emailBody = Console.ReadLine();
    
                    Gmail.sendMail(emailAddress, emailPassword, emailRecipient, emailSubject, emailBody);
                }
                else
                {
                    Console.WriteLine("Please enter G-Mail credentials!");
                }
    
    
            }
    
            static void enterEmail()
            {
                Console.Write("E-Mail Address: ");
                emailAddress = Console.ReadLine();
                Console.Write("E-Mail Password: ");
                emailPassword = Console.ReadLine();
            }
    
            static Boolean loggedIn()
            {
                if (emailAddress == "" || emailPassword == "")
                {
                    isLoggedIn = false;
                    return false;
                }
                else
                {
                    isLoggedIn = true;
                    return true;
                }
            }
    
            static int showMenu()
            {
                if (isLoggedIn == false)
                {
                    Console.WriteLine("_____MENU_____");
                    Console.WriteLine("1. Enter G-Mail Credentials");
                    Console.WriteLine("2. Exit Application");
                    Console.Write("What would you like to do? ");
                    selection = Convert.ToInt32(Console.ReadLine());
                    return selection;
                }
                else if (isLoggedIn == true)
                {
                    Console.WriteLine("_____MENU_____");
                    Console.WriteLine("1. Change G-Mail Credentials");
                    Console.WriteLine("2. Exit Application");
                    Console.WriteLine("3. Check Mail");
                    Console.WriteLine("4. Send Mail");
                    Console.Write("What would you like to do? ");
                    selection = Convert.ToInt32(Console.ReadLine());
                    return selection;
                }
                else
                {
                    return 0;
                }
    
            }
        }
    }
    
    
  2. In Topic: SMTP Interfacing Application Various Problems

    Posted 24 Feb 2015

    I was trying to work it out on my own before I try and lay out the methodology behind it.

    Once I get home from work I will try again using a dedicated variable to store it.

    Another thing I forgot to add: would it be better to do the showMenu() method as I did in the first bit of code where I seperated the loggedIn() true and loggedIn() false showMenu() methods. So the if statement would be in the Main method instead of in the showMenu() method?

    I'll most likely be back!

    Thanks,
    Andrew

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

LazerKittenz has no profile comments yet. Why not say hello?