-5

I am using gmail to send email from C# program, my question is that email found under sent items if logged in into gmail.com via browser? if I am sent an email from c# program and that email fails(bounce back) then Is failover notification found if I am logged in into gmail.com via browser?

if yes , then is there any additional settings to receive that? I want to show that in gmail.com via browser when I am login.

skiskd
  • 423
  • 2
  • 9
  • 20
  • 7
    Why don't you try it and find out? – Ben Robinson Sep 08 '15 at 10:06
  • the only certain thing is that if you send too many at an instance, gmail blocks external apps them and then you have to unblock them – elasticrash Sep 08 '15 at 10:07
  • @elasticrash- I am sending only 2 or 3 email from c# program per day, not more than that. my aim is to it can be viewed from gmai.com via browser also. any idea about that? – skiskd Sep 08 '15 at 10:10
  • if your question is "does emails send from a c# app" appear in send mail. then the answer is YES – elasticrash Sep 08 '15 at 10:17
  • @BenRobinson- I tried but, it has not found in from address field, and I don't have smtp mail user access. so not able to check,can you please help on this? – skiskd Sep 08 '15 at 10:48

1 Answers1

0

I don't really understand what you are asking but if you just need the code to send emails through gmail it is pretty simple

 void SendMail_Click(object sender, EventArgs e)
        {
            var email = new Dto.IEmail();
            if (EmailBody.Text == string.Empty && EmailSubject.Text == string.Empty)
            {
                XtraMessageBox.Show("please fill email body and subject");
                return;
            }
            email.Body = EmailBody.Text;
            email.Subject = EmailSubject.Text;
            email.EmailAddress = "email@gmail.com";
            email.ToAddress = "email@gmail.com";

            try
            {
                MailMessage message = new MailMessage();
                SmtpClient smtp = new SmtpClient();

                message.From = new MailAddress(email.EmailAddress);
                message.To.Add(new MailAddress(email.ToAddress));
                message.Subject = email.Subject;
                message.Body = email.Body + "\n From user " + GlobalClass.UserLogin.USERNAME + "\n with body: " + _reportedfile;

                smtp.Port = 587;
                smtp.Host = "smtp.gmail.com";
                smtp.EnableSsl = true;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new NetworkCredential(email.EmailAddress, "gmailpassword");
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtp.Send(message);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("err: " + ex.Message);
            }
        }
elasticrash
  • 1,181
  • 1
  • 12
  • 30
  • I can understand and worked your suggested. But my problem is when I am trying smtp.Credentials like ("xyz@gmail.com","pwd") and MailMessage message.From ="abc@gmail.com" and TO-"aaa@gmail.com", in this case email sent successfully and also received by intended recipient,but when I am logged in into gmail.com, I can't found this such email in SENT items of "xyz@gmail.com" nor in "abc@gmail.com". so where I can found this send email in SENT item? in which account SENT items logged? – skiskd Sep 09 '15 at 06:30
  • I used the above many times and the send emails are indeed in the send folder. But you have to activate Gmail to accept custom 3rd party custom apps or else it might reject completely the email. – elasticrash Sep 09 '15 at 06:33
  • correct, but emails are successfully sent and received. but only concerned is to where gmail logs the sent item , is that in abc@gmail.com or in xyz@gmail.com? – skiskd Sep 09 '15 at 06:51