Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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
  #1 (permalink)  
Old May 25th, 2008, 10:04 AM
Authorized User
 
Join Date: Jan 2008
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Doom
Default System.Net.Mail Problems With Sending An Email

Here is my code

Code:
using System;
using System.Net;
using System.Net.Mail;

class MainClass
{
    public static void Main()
    {
        {

            //send the message
            SmtpClient smtp = new SmtpClient("smtp.gmail.com");
            smtp.Port = 465;
            smtp.EnableSsl = true;
            //to authenticate we set the username and password properites on the SmtpClient
            smtp.Credentials = new NetworkCredential("doom1992", "MYPASSWORD-THIS IS NOT MY REAL PASSWORD");

            //create the mail message
            MailMessage mail = new MailMessage();

            //set the addresses
            mail.From = new MailAddress("doom1992@googlemail.com");
            mail.To.Add("stevie5@hotmail.co.uk");

            //set the content
            mail.Subject = "This is an email";
            mail.Body = "this is the body content of the email.";
            smtp.Send(mail);
        }
    }
}
I get NO erros in the IDE but the server keeps on timing out.

Can anyone help



  #2 (permalink)  
Old May 25th, 2008, 01:35 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Seeing as this compiles it is likely either a networking issue or one to do with the settings you have entered.

Perhaps google requires your full email address in the network credentials line?

/- Sam Judson : Wrox Technical Editor -/
  #3 (permalink)  
Old May 25th, 2008, 01:55 PM
Authorized User
 
Join Date: Jan 2008
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Doom
Default

tried that. It didnt work. It might be somthing to do with the google server. Any Other Suggestions. I will try and do it on my local server. If it works on there that way i will no it is somthing to do with google servers.

  #4 (permalink)  
Old May 25th, 2008, 02:49 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Do you have a proxy server perhaps? Otherwise I have no idea I'm afraid.

/- Sam Judson : Wrox Technical Editor -/


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Net.Mail Problem With Time Out When Sending Adam Thompson Visual Basic 2005 Basics 5 November 10th, 2012 05:24 AM
problems sending mail with java mail gandacuboy J2EE 2 December 20th, 2006 03:05 PM
embed images in email using system.net.mail Looney Classic ASP Basics 1 June 7th, 2005 05:11 PM
Email not sending with mail() jeffrowe BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 March 1st, 2005 07:23 PM





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