View Single Post
  #1 (permalink)  
Old June 14th, 2012, 08:23 AM
Rajasekar1988 Rajasekar1988 is offline
Registered User
Points: 41, Level: 1
Points: 41, Level: 1 Points: 41, Level: 1 Points: 41, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default SMTP EMAIL NOT WORKING

Hi Imar,

I'm currently in the excercise how to send email from ur web page.
The Specifiedpickupdirectory is working fine bt sending from mail to mail not working as it says timeout expired.

As i've already searched the forums and couldn't able to get a solution. Another guy is also having the same problem as i in which he also needs solution. But he's having a different error. so please help me to get a solution.

Here's my code

Code:
Email.aspx.cs
-------------

protected void Page_Load(object sender, EventArgs e)
    {
        MailMessage myMessage = new MailMessage();
        myMessage.Subject = "Text Message";
        myMessage.Body = "Hello World, Welcome To Planet Wrox";
        myMessage.From = new MailAddress("my@gmail.com", "Developer");
        myMessage.To.Add(new MailAddress("my@gmail.com", "Developer"));

        SmtpClient mySmtpClient = new SmtpClient();
        mySmtpClient.Send(myMessage);
    }


Web.config
-----------

<?xml version="1.0"?>

<configuration>

  <system.web>
        <compilation debug="true" targetFramework="4.0" />
      <pages theme ="Monochrome">
        <controls>
          <add tagName="Banner" tagPrefix="Wrox" src ="~/Controls/Banner.ascx"/>
        </controls>
      </pages>
    </system.web>
  <system.net>
  <mailSettings>
    <!--<smtp deliveryMethod ="SpecifiedPickupDirectory">
      <specifiedPickupDirectory pickupDirectoryLocation ="c:\TempMail" />-->
    <smtp deliveryMethod="Network" from="my@gmail.com">
      <network enableSsl ="true" userName="myusername" password="mypassword" host="smtp.gmail.com" port="465"/>
    </smtp>
    
    <!--<smtp deliveryMethod="Network" from="&lt;myemail&gt;">
      <network enableSsl="true" userName="username" password="pwd" host="smtp.gmail.com" port="587"/>
    </smtp>-->
  </mailSettings>
  </system.net>
</configuration>

Last edited by Rajasekar1988; June 15th, 2012 at 12:23 AM..
Reply With Quote