Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
| Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2013, 11:25 AM
Registered User
Points: 52, Level: 1
Points: 52, Level: 1 Points: 52, Level: 1 Points: 52, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2013
Posts: 12
Thanks: 5
Thanked 0 Times in 0 Posts
Default hello I need help with sending a mail trough webform

hello this is the code i am using:

private String SendMail(String CorreoDestino, String Asunto, String Cuerpo)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("hp88.hostpapa.com");
mail.From = new MailAddress("mailadress@mail.com", "Host", Encoding.UTF8);
mail.Subject = Subject;
mail.Body = Body;
mail.To.Add(CorreoDestino);
SmtpServer.Port = 25;
SmtpServer.Credentials = new System.Net.NetworkCredential("emailsender@mail.com ", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
return "Enviado";
}

catch (Exception ex)
{
return ex.Message.ToString();
}


the sender button:

protected void btnEnviar_Click(object sender, EventArgs e)
{
string TextToSend = txtTextToSend.Text;
String MenConfirmacion = "";
MenConfirmacion = SendMail("MailDestiny@mail.com", "e-mai header", TextToSend);
lblmen.Text = Mensaje;
}
 
Old September 28th, 2013, 09:36 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
this is the code i am using:
And what about describing what the actual problem is?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
light882 (October 2nd, 2013)
 
Old September 30th, 2013, 11:15 AM
Registered User
Points: 52, Level: 1
Points: 52, Level: 1 Points: 52, Level: 1 Points: 52, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2013
Posts: 12
Thanks: 5
Thanked 0 Times in 0 Posts
Smile thnx for the reply

the problem is that the code doesn´t show any error but the email is not send, thnx for your help
 
Old September 30th, 2013, 01:32 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Try removing the try/catch block and see what the real error is. My guess is that it has to do with the configuration of the server, user name, password or port (for example, SSL and port 25 probably won't work together). Without the real error, it's hard to tell what's going on.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
light882 (October 2nd, 2013)
 
Old October 2nd, 2013, 03:32 PM
Registered User
Points: 52, Level: 1
Points: 52, Level: 1 Points: 52, Level: 1 Points: 52, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2013
Posts: 12
Thanks: 5
Thanked 0 Times in 0 Posts
Post yes the change of the port was the result thank you

it worked because on the proyect the mail was on a diferent port, thank you very much, I have another question, please I want to know how to make an pageIndex on a gridview, I´m using this code:


protected void dtgBusqueda_SelectedIndexChanging(object sender, GridViewPageEventArgs e)
{
dtgBusqueda.PageIndex = e.NewPageIndex;
ViewState["Busqueda"] = Session["oTransaction"];
//filling the gridview
dtgBusqueda.DataSource = (DataTable)ViewState["Busqueda"];

}

when i do this the GridViewPageEventArgs changes for a GridViewSelectEventArgs again and I don´t know why
 
Old December 4th, 2013, 06:02 AM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2013
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you




Similar Threads
Thread Thread Starter Forum Replies Last Post
mail sending PHP FAQs 0 April 2nd, 2007 06:43 AM
problems sending mail with java mail gandacuboy J2EE 2 December 20th, 2006 03:05 PM
Sending e-mail to different mail box! Calibus Classic ASP Databases 4 September 3rd, 2004 05:48 PM
sending an e-mail Calibus Classic ASP Databases 3 August 22nd, 2004 07:45 PM
Sending both text mail and HTML mail - CDONTS madhukp Classic ASP Basics 1 October 8th, 2003 01:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.