error message when sending email through gmail #2

i got the error message when i tried to send email through gmail:


The operation has timed out.

The operation has timed out.

this is my code:

Dim mail As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()


mail.Subject = "automatically sent email "

mail.From = New System.Net.Mail.MailAddress("")

mail.Body = "If you receive this email, it means you don't need your own email server to send email through internet. You may use gmail server. This message has been sent programmatically with GMail."

mail.IsBodyHtml = False

Dim credential As System.Net.NetworkCredential = New System.Net.NetworkCredential("", "myPassword")

Dim smtp As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient("")

smtp.UseDefaultCredentials = False

smtp.Credentials = credential

smtp.EnableSsl = True

smtp.Port = 465 'also tried 587, 25



i posted the same subject several days ago.  last time i got different error message:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

the replies suggested i should change setting on my firewall settings.  since i didn't have control over that computer, i couldn't try how changing the firewall settings would affect the code.  now i am at my own computer and i got the new error message.

Can anybody help?  Thanks in advance.


Please mark replies that have helped you as answers.
5/25/2008 5:30:07 PM 93655 articles. 5 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 49

Hi friend,

Please refer the following code, and try again,


//This is fully working tested code. Copy and paste the code
//Edit some parts(UserName, password) and ENJOY!
public string sendMail (string from, string to, string cc, string bcc, string subject, string body) {
    // Mail initialization
    MailMessage mailMsg = new MailMessage();
    mailMsg.From = from;
    mailMsg.To = to;
    mailMsg.Cc = cc;
    mailMsg.Bcc = bcc;
    mailMsg.Subject = subject;
    mailMsg.BodyFormat = MailFormat.Text;
    mailMsg.Body = body;
    mailMsg.Priority = MailPriority.High;
    // Smtp configuration
    SmtpMail.SmtpServer = "";
    // - use smtp authentication
    mailMsg.Fields.Add("", "1");
    mailMsg.Fields.Add("", "");
    mailMsg.Fields.Add("", "mypassword");

    // - use port 465 or 587
    mailMsg.Fields.Add("", "465");
    // - use STARTTLS (some call this SSL)
    mailMsg.Fields.Add("", "true");
    // try to send Mail
        return "";
    catch (Exception ex)
        return ex.Message;



More information, please visit this link:

Hope it helps,

Hong Gang 

Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
5/29/2008 5:45:14 AM

After I have spent so much time testing the code, it didn't work at all.  I also visited the link.  it is very disappointing. 


Please mark replies that have helped you as answers.
5/30/2008 4:08:00 PM

 This code is working:


protected void Button1_Click(object sender, EventArgs e)
    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

    System.Net.NetworkCredential cred = new System.Net.NetworkCredential("", "urpassword");

    mail.Subject = "subject goes here";

    mail.From = new System.Net.Mail.MailAddress("");
    mail.IsBodyHtml = true;
    mail.Body = "This message has been sent programmatically with GMail";

    System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("");
    smtp.UseDefaultCredentials = false;
    smtp.EnableSsl = true;
    smtp.Credentials = cred;
    smtp.Port = 587;

Mark as Answer if the post was useful to you

Rajesh Thangarasu
Microsoft Certified Professional
5/31/2008 10:48:12 AM

Similar Artilces:

send web email from web form error help
Hi, When send email with attachment from web form. I got an error message as below. What it is? Can someone help? Server Error in '/dotNet' Application. -------------------------------------------------------------------------------- The transport lost its connection to the server. Hi There, Please check the following link The transport failed to connect to the server Hope this helps Sunny NAGIProper Preparation Prevents Poor PerformanceDont forget to click "Mark as Answer" on the post that helped you....

Sending an Email message from a web form
I used pretty typical code copied from an example: Dim MailMsg As New MailMessageMailMsg.To = ""MailMsg.Subject = TextBoxSubject.TextMailMsg.Body = TextBoxMessageText.TextMailMsg.From = TextBoxAddr.TextSmtpMail.SmtpServer = "localhost"SmtpMail.SmtpServer = ""SmtpMail.Send(MailMsg)I am on a home PC, with DSL provider Verizon.  Outlook is working for me to send/receive mail.When i tried SmtpMail.SmtpServer= "localhost", i got the following exception:The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to ...

Sending Email Messages Error #2
Hi All I have a simple application that sends emails which I got from This works fine on my pc when in Delphi XE2 environment and also when I run the .exe on my pc. When running the .exe on other pcs on the network (that have email and network capabilities) I get a error message:- "ERROR: Service not available Status: Disconnected. Status: Disconnecting. Status: Connected. Status: Connecting to Status: Resolving hostname Serv-mail01.Serv.local." I've run as Admin and still the same error. ...

error message when sending email through Gmail
I got the following error message when I tried to send email through gmail: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond I know the following code is correct because many people use the same code and it works.  I set the POP enabled in the gmail account.  Can anybody tell me what has caused this error?  Thanks in advance.Dim mail As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage() mail.To.Add(""...

Trying to send an email from a web form #2
I'm trying to send an email from a web form:  MailMessage Msg = new MailMessage(); Msg.To.Add(new MailAddress(ToPerson));Msg.From = new MailAddress(FromPerson); Msg.Subject = Subject; Msg.Body = BodyText;Msg.BodyEncoding = System.Text.Encoding.UTF8; Msg.SubjectEncoding = System.Text.Encoding.UTF8;Msg.Attachments.Add(new Attachment(FileName)); SmtpClient Client = new SmtpClient("");Client.Send(Msg); I get  the exceptions: Unable to send email Unable to connect to remote server  What should I be specifying as the remote server for the smtp c...

Send email error from my web form question
I keep getting this fatal error when I try to send email from my web form internally.  For some reason, when I set the (to) address to a valid email address that is external it works, but when I try sending a valid email internally it will not work.  I even broke the mail function down to the bare minimum to send a sample email.  I even hard coded the addresses right in the (to) and (from) fields.  No matter what I try, it produces the same results.  If I change the (to) email address to anything external, it will work perfectl...

Sending Email with Net.Mail (No Email, no error)
hi,i'm using the namespace to send an email from my application. when i send, the application does not fire any exception, neither does it send the email to my account.below is the code i'm using  Dim mmailMessage As New Net.Mail.MailMessage Dim mFrom As New Net.Mail.MailAddress(mailFrom) mmailMessage.From = mFrom Dim ll As String = "" mmailMessage.To.Add(ll) mmailMessage.Subject = "Talk Concerns" mmailMessage.Body = "Testing Concerns One Two" Dim ...

Sending Email from web page-send.objmm error
when icomile the code th folowing error come .I have downloaded the code from .and run it but it give me followin error . ****************************************************** The "SendUsing" configuration value is invalid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is in...

Submitting Web forms fields to sql database by clicking on SUBMIT FORM and sending the form fields to email box
I have a created or designed a form to be stored in a SQL database table and at the same time when a user clicks on SUBMIT button the form fields will automatically goto the visitor email address immediately. Also i have created a database with tables for each of this forms Pls help i have over 10 forms designed but the problem of submitting them to the table database and the user email address is the challenge now.... You ned to familiarise yourself with the basics of database access in ASP.NET.  There are free tutuorials here:

I recently moved three of my working DNN sites to a new server.  I discovered that after the move..NONE of my emails from the DNN sites work.  I get this error when I try to send an email through the bulk email feature:  ErrorCode: -2147467259Message: Could not access 'CDO.Message' object.InnerException: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80040220): The "SendUsing" configuration value is invalid. --- End of inner exception stack trace --- at System.Runtim...

C# email form doesn't send email, but no compilation errors
I'm trying to get an email form to work.  It is a feedback form.  I wrote it in C#. The existing code returns no compilation errors and appears to work, but the email never gets delivered.  Is there something simple I'm forgetting about?  The email is a godaddy account.  I'm not sure if that has anything to do with it, but godaddy didn't help me at all so now I'm at a loss on what to do next. <%@ Page Language="C#" Explicit="true" MasterPageFile="~/MasterPage.master" %><%@ Import NameSpace="System....

Sending Email through System.Net.Mail is generating errors "Failure Sending mail
hi Sending Email through System.Web.Mail is working fine but System.Net.Mail is generating errors "Failure Sending mail  i treid in all possible ways but did't  pls help in giving a solution thanks & Regards vittal Maybe you can show us some code and post the exact error mesg as well (by looking at the value in ex.tostring)?My HomePage -"It is more blessed to give than to receive." Acts 20: 35 (NIV, Bible)Progress - "Never discourage anyone...who continually makes progress, no matter how slow." Plato System.Web.Ma...

Send email from web form???
Hi there .. Iam trying to send email using SmtpMail Component but i get this error at runtime "The "SendUsing" configuration value is invalid" here is the code MailMessage myMailMessage = new MailMessage(); myMailMessage.From = ""; myMailMessage.To = ""; myMailMessage.Subject = "User Name and Password"; myMailMessage.Body = "Your Username : wafi and <br> Password : wafi"; myMailMessage.BodyFormat = MailFormat.Html; SmtpMail.Send(myMailMessage); any...

Send the web form to an email
I have made a web page. The user need to fill the web page and on submit button the form need to be send the email. But my problem is that I have to send the page as it looks like with the data filled by the user. You can create a link for viewing the filled form. On click on the submit button the link should be sent in the email. Ensure all textboxes are readonly on the page when the user is viewing the entered values. Thank You~B  Saurav Bhadani:I have made a web page. The user need to fill the web page and on submit button the form need to be...

Web resources about - error message when sending email through gmail #2 -

Message - Wikipedia, the free encyclopedia
A message is a discrete unit of communication intended by the source for consumption by some recipient or group of recipients. A message may ...

Islamic State loses key dam in Syria as leader threatens West in message
The Islamic State group has released a new message purportedly from its reclusive leader, claiming that his self-styled “caliphate” is doing ...

ISIS' leader resurfaces in new audio message - Videos - CBS News
It's more than half a year since the world heard from Abu Bakr al-Baghdadi, the reclusive leader of ISIS. Jonathan Vigliotti reports on his latest ...

De-Stress By Watching 30-Minutes of an Adorable Puppy Getting a Message
Submitted by: (via BuzzFeed ) Tagged: dogs , relaxing , puppy , buzzfeed , message , Video Share on Facebook

President Obama's Christmas Eve message on Christian persecution sounds 'strange,' even 'crazy' to critics ...
Conservative critics remained dubious of the real intention of U.S. President Barack Obama even after he issued a statement on Christmas Eve ...

How did Warriors turn around after halftime? 'Steve had a nice message'
Enter to win prizes during the entire month of January! You can win tickets to a Warriors game, CSN studio tours, a chance to attend the Coaching ...

One Analyst Has A Clear Message For The GOP On Obama’s Big Paris ‘Treaty’
One Analyst Has A Clear Message For The GOP On Obama’s Big Paris ‘Treaty’

Christmas Lights Bring Seasonal Anti-Gentrification Message to Bushwick
&quot;Mi casa no es su casa&quot; and &quot;Not 4 Sale,&quot; the signs read. BUSHWICK — A lifelong resident of Bushwick tired of being hassled ...

Demi Lovato and Wilmer Valderrama Mourn the Loss of Their Dog, Spawn, With a Heartbreaking Message
Demi Lovato and Wilmer Valderrama Mourn the Loss of Their Dog, Spawn, With a Heartbreaking Message

The Five Loudest Messages You're Sending Your Employees
What messages are you sending to your employees without even realizing it? Here are five of the loudest ones!

Resources last updated: 1/1/2016 10:03:22 AM