using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void username_TextChanged(object sender, EventArgs e)
{
}
private void userplot_TextChanged(object sender, EventArgs e)
{
}
private void userreason_TextChanged(object sender, EventArgs e)
{
}
private void sendrequest_Click(object sender, EventArgs e)
{
string user = username.Text;
string plot = userplot.Text;
string reason = userreason.Text;
string all = user + " - " + plot + " - " + reason;
System.IO.File.CreateText (all);
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "Test Mail - 1";
mail.Body = all;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "**********");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
Rewant ChoudharyPosted Sep 6, 2012, 1:32 AM
Try{
//your code here
label.text="Mail sent";
}
catch(exception ee)
{
messagebox.show(ee.Tostring());
}
now check your inbox and Spam folder also
Thanks
Robert WiedemanPosted Sep 5, 2012, 10:28 AM
(Thnx for trying to help me out btw).
Rewant ChoudharyPosted Sep 5, 2012, 9:19 AM
mail.Bcc.Add("[email protected]");
mail.From = new MailAddress("[email protected]", "WebAccouting");
mail.Subject = "Feedback...!!!";
mail.Body = "body";
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential("GmailID", "password");
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Send(mail);
It's tested and working fine.
Note in NetworkCredential are you using gmail id and password or not.
copy and paste and check your network connection also.
what is error can you show me..
Robert WiedemanPosted Sep 5, 2012, 9:08 AM
using System;
Rewant ChoudharyPosted Sep 5, 2012, 6:15 AM
MailMessage mail = new MailMessage();
mail.Bcc.Add("[email protected]");
mail.From = new MailAddress("[email protected]", "WebAccouting");
mail.Subject = "Feedback...!!!";
mail.Body = "body";
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential("GmailID", "password");
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Send(mail);