473,569 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem sending mail through Gmail

2 New Member
Ugh this is so frustrating. This code doesn't work for some reason...Can anybody help me fix it?

Expand|Select|Wrap|Line Numbers
  1. class MainClass
  2.     {
  3.         public static void Main (string[] args)
  4.         {
  5.             MainClass mailman = new MainClass();
  6.             mailman.Mailer();
  7.         }
  8.  
  9.         public void Mailer ()
  10.         {
  11.         try
  12.            {
  13.                 MailMessage mail = new MailMessage();
  14.                 SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com",465);
  15.  
  16.                 mail.From = new MailAddress("myemail@gmail.com");
  17.                 mail.To.Add("otheremail@gmail.com");
  18.                 mail.Subject = "Test Mail";
  19.                 mail.Body = "This is for testing SMTP mail from GMAIL";
  20.  
  21.                 SmtpServer.Credentials = new System.Net.NetworkCredential("myemail@gmail.com", "password");
  22.                 SmtpServer.EnableSsl = true;
  23.  
  24.                 SmtpServer.Send(mail);
  25.                 Console.WriteLine("SENT");
  26.            }
  27.         catch
  28.             {
  29.                 Console.WriteLine("ERROR");
  30.             }
  31.  
  32.         }
  33.     }
It doesnt even have an error. It sometimes says ERROR due to the catch statement but now it doesnt display anything just the console cursor thing blinks for ever...
Jun 29 '10 #1
3 1789
Plater
7,872 Recognized Expert Expert
You have to enable smtp access per gmail account in their settings
Jun 29 '10 #2
AbusiveMeercat
2 New Member
How can you do that in gmail.com? I dont use a outside email program...
Jun 29 '10 #3
Plater
7,872 Recognized Expert Expert
Its under settings. google has a whole tutorial on it.
Jun 30 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2367
by: Gerhard Häring | last post by:
On my mailserver (running a recent Postfix snapshot) I get this since a few hours: mylene:/var# mailq -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- DA10713E37 1617 Wed Sep 3 11:32:46 gh@ghaering.de (lost connection with mail.python.org while sending end of data -- message may be sent more than once)...
3
5855
by: Serge Myrand | last post by:
Hi everybody, The following code for sending email (found on msn I think) works find when used in a .VBS file. I double click the file and the mail is send. When I use the same code in my .ASP application I get the following message: "The pickup directory path is required and was not specified" Where to specify that directory?
2
4588
by: Brent | last post by:
Hi, I have a C# asp.net app that sent mail fine on server 2000 or win 2000, but now I moved it to our new 2003 box, and it's giving me "The 'SendUsing' configuration is invalid" This is the code now... MailMessage mail = new MailMessage(); mail.From = from;
1
1081
by: Robert Dufour | last post by:
I a m trying to send e-mails using the system.net.mail in framework2. I have IIS installed on my test box and the smtp service is started. I can use outlook on that box to send and receive my e-mails OK, my firewall ports 25 and 53 are open (using isa server 2004 as firewall), the local machine (Win XP Pro SP2) firewall is off. My code...
0
1276
by: Parz | last post by:
Hi can somebody please help me.. I have a web page from which the new members can mail me with their details.What i have done is, I have created a form with all details and an attachment upload option,then on submit .It goes to the next page,which retrieves the values of all the fields..n sends it as a mail in the body..But am not bale to attach...
0
1540
by: Pav | last post by:
Hi, I am developing a small Intranet web application which needs to send mails to our coporate Ids. I am using CDONTS, But my mails never leave Que folder. Not able to find out what the problem is . please help 1) I am very new to SMTP configiration on my own Windows XP PC. How do
1
976
by: =?Utf-8?B?amVuaWx5bm4xMjM=?= | last post by:
I set up my windows mail email a few days ago and it worked fine. Now, I can recieve email, but I cannot send it. I don't know what to do. It was fine and I haven't changed any settings. Please help me. Jen
2
4543
by: prasenjit2007 | last post by:
Hello, can u help me sending Email with attachments using the Class phpMailer. On the website I have a link to an html form in which I input the parameters with the names 1)from(textbox name) 2)To 3) Subject 4) Message5) File input(name abc) - to be sent as an attachment. This form calls the Class PhpMailer through another form with the...
4
2964
by: bgs | last post by:
i'm trying to send mail from asp server in two ways, the first uses CDONTS.Newmail: <% Dim objCDOMail Set objCDOMail = Server.CreateObject("CDONTS.NewMail") objCDOMail.BodyFormat = 1 objCDOMail.Subject="test"
4
1765
by: vivekshekar | last post by:
I'm using Ubuntu OS, I'm trying to send a mail through a program, but I'm not able to do this. This is the program, <?php $Name = "xxx";
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7673
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.