p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Basics (http://p2p.wrox.com/forumdisplay.php?f=136)
-   -   Sending Autoamtic Email (http://p2p.wrox.com/showthread.php?t=67299)

abhas_mc60 April 10th, 2008 01:54 AM

Sending Autoamtic Email
 
Hai
I 'm encountering some problem when i tried to send the email using following code:-

using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net;
using System.Net.Mail;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //Create a new MailMessage object and specify the "From" and
        "To" addresses
        MailMessage Email = new MailMessage
                         ("my_email_id@gmail.com",TextBox1.Text);
        Email.Subject = "test subject";
        Email.Body = "this is a test";
        SmtpClient mailClient = new SmtpClient();
        //This object stores the authentication values
        NetworkCredential basicAuthenticationInfo = new
               NetworkCredential("my_email_id@gmail.com",
                        "my gmail password");
        //Put your own, or your ISPs, mail server name on this next
        // line
        mailClient.Port = 465;
        mailClient.Host = "smtp.gmail.com";//
                  "smtp.gmail.com"
        mailClient.UseDefaultCredentials = false;
        mailClient.Credentials = basicAuthenticationInfo;
        mailClient.Send(Email);
    }
}

//Text box "TextBox1" contains the email id i'm sending the mail to

The problem i'm encountering is:-
         "The remote name could not be resolved: 'smtp.gmail.com"

Plz help me out as soon as possible!!!!!


planoie April 10th, 2008 08:56 AM

Have you done any testing to see if the URL in question is resolvable on the machine this page is running on?

-Peter
peterlanoie.blog


All times are GMT -4. The time now is 06:37 AM.

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