about mail delivery system

Posted by reddysankark-13471 under ASP.NET on 3/2/2012 | Points: 10 | Views : 1552 | Status : [Member] | Replies : 5
actually i will give mail id in my text box but its not sending.i don't know why its not sended.can any body help me

try
{
//textbox3.text is we can give mail id in that

MailAddress mailfrom = new MailAddress("TextBox3.Text");
MailAddress mailto = new MailAddress("sankarreddyece@gmail.com");
MailMessage newmsg = new MailMessage(mailfrom, mailto);

newmsg.Subject = "Subject of Email";
newmsg.Body = "Body(message) of email";

////For File Attachment, more file can also be attached

//Attachment att = new Attachment ( "G:\\code.txt" );
//newmsg.Attachments.Add ( att );

SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587);
smtps.UseDefaultCredentials = false;
smtps.Credentials = new System.Net.NetworkCredential("sankarreddyece@gmail.com", "640");
smtps.EnableSsl = true;
smtps.Send(newmsg);
//MessageBox.Show("mail Send");

}

catch (Exception ex)
{

//MessageBox.Show(ex.ToString());

}

sankarreddy


Responses

Posted by: Blessyjees on: 3/2/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Are you getting any error?

Can you try with one gmail id as fromaddress

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.Saravanan on: 3/6/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

I think issue is in your code. Kindly change the following line in your code...

MailAddress mailfrom = new MailAddress(TextBox3.Text );

instead of
MailAddress mailfrom = new MailAddress("TextBox3.Text");


Thanks,
T.Saravanan

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/6/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi try this code:

try
{
//textbox3.text is we can give mail id in that

MailAddress mailfrom = new MailAddress("sankarreddyece@gmail.com");
MailAddress mailto = new MailAddress("TextBox3.Text");
MailMessage newmsg = new MailMessage(mailfrom, mailto);

newmsg.Subject = "Subject of Email";
newmsg.Body = "Body(message) of email";

////For File Attachment, more file can also be attached

//Attachment att = new Attachment ( "G:\\code.txt" );
//newmsg.Attachments.Add ( att );

SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587);
smtps.UseDefaultCredentials = true;
smtps.Credentials = new System.Net.NetworkCredential("sankarreddyece@gmail.com", "640");
smtps.EnableSsl = true;
smtps.Send(newmsg);
//MessageBox.Show("mail Send");

}

catch (Exception ex)
{

//MessageBox.Show(ex.ToString());

}


Mark this as answer if it helps you, that motivates.....

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: reddysankark-13471 on: 3/7/2012 [Member] Starter | Points: 25

Up
0
Down
try
{

MailAddress mailfrom = new MailAddress("sankarreddyece@gmail.com");
MailAddress mailto = new MailAddress(TextBox3.Text);
MailMessage newmsg = new MailMessage(mailfrom, mailto);

newmsg.Subject = "Subject of Email";
newmsg.Body = "Body(message) of email";

////For File Attachment, more file can also be attached

//Attachment att = new Attachment ( "G:\\code.txt" );
//newmsg.Attachments.Add ( att );

SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587);
smtps.UseDefaultCredentials = false;
smtps.Credentials = new System.Net.NetworkCredential("sankarreddyece@gmail.com", "640");
smtps.EnableSsl = true;
smtps.Send(newmsg);
//MessageBox.Show("mail Send");

}


i will try this coding its does not show any error.email also not sent what will be problem

sankarreddy

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 3/7/2012 [Member] Silver | Points: 25

Up
0
Down

Please make sure you have given your gmail user name and password for NetworkCredential...
smtps.Credentials = new System.Net.NetworkCredential("sankarreddyece@gmail.com", "640");

Also refer this link
http://support.google.com/mail/bin/answer.py?hl=en&answer=13287

reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response