473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem sending mail through Gmail

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 1781
Plater
7,872 Expert 4TB
You have to enable smtp access per gmail account in their settings
Jun 29 '10 #2
How can you do that in gmail.com? I dont use a outside email program...
Jun 29 '10 #3
Plater
7,872 Expert 4TB
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
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...
3
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...
2
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...
1
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...
0
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...
0
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...
1
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...
2
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)...
4
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 ...
4
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.