-3

I have a gmail id for my school's account. once I give that id, it will direct me to my school's website where i enter my username and password.

Now I tried to create an application using Visual Studio 17 where I can send mail directly using an app. But it is not getting through. My id passwords do not match probably I guess. Why I'm telling this is, when I tried with my other gmail id and password it worked. But since this gmail id is with my school id, it is not going through.

this is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;

namespace mail
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }


      

        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {   
                String Subject = "ATSO " +checkBox1.Text + " Assesment " + radioButton1.Text;
                String st = "This is a confirmation mail for your appointment with Daminna on" + dateTimePicker1.Text  + " You do not have to carry your laptop";
                //MailMessage msg = new MailMessage("krishchan1994@gmail.com", textBox1.Text, "TEST TEST TEST", textBox2.Text);
                SmtpClient mail = new SmtpClient("smtp.gmail.com", 587);
                mail.EnableSsl = true;
                
                mail.DeliveryMethod = SmtpDeliveryMethod.Network;
                mail.UseDefaultCredentials = false;
                mail.Credentials = new NetworkCredential("krishnan.chandran@csueastbay.edu", "mypassword");
                MailMessage msg = new MailMessage();
                msg.To.Add(textBox1.Text);
                msg.From = new MailAddress("krishnan.chandran@csueastbay.edu");
                msg.Subject = "ATSO Assessment Confirmation";
                msg.Body = st;
                mail.Send(msg);
                MessageBox.Show("Message sent Successfully XD .!");
            }
            catch(Exception ex)
            {
                MessageBox.Show("FAIL");
            }

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {

        }
    }
}

This is my gmail login: IF you see I select one account there. enter image description here

Here, again i enter my school's ID and Password. enter image description here

So after all this, I get confused with the mail id and the smtp related to it. I have a school id and also a gmail id related to it. Now Should I enter which one in my code.

Community
  • 1
  • 1
  • That isn't your code. It's a picture. What are we supposed to do with a picture? Show your code if you want help. [mcve] – Rob Jul 29 '17 at 00:40
  • Images of code are absolutely useless to us. See [this Meta post](https://meta.stackoverflow.com/a/285557/62576) for a list of the many reasons why you should not post your code as an image. – Ken White Jul 29 '17 at 00:42
  • sorry. I changed it now – Krish Chandran Jul 29 '17 at 02:28

1 Answers1

0

You should be able to use the same instructions for programming SMTP access as you do for accessing your mail account from a standalone mail client.

Your university seems to have proper instructions uploaded over here:

http://www.csueastbay.edu/googleapps/entourage-users.html

(I refer to the entourage guide as they use standard protocols and authentication with that instead of OAuth access via the Android and iPhone mail stuff)

Mastacheata
  • 1,866
  • 2
  • 21
  • 32
  • Sorry I'm new to this area of study. I did not understand this entourage. Is this a software that i should download? – Krish Chandran Jul 29 '17 at 02:24
  • Nah, I meant using the configuration info for entourage with your code. The Entourage instructions cover all the neccessary infos: Servers, ports, how to format username and password etc. The other guides on the site leave out important details and can't be adapted to other mail clients or programming frameworks so easily. – Mastacheata Jul 29 '17 at 15:17