Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8291237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:03:36+00:00 2026-06-08T13:03:36+00:00

I am trying to create a program that queries a database and exports reports

  • 0

I am trying to create a program that queries a database and exports reports to excel and then emails out the status, I am stuck on the email part. I keep getting “Failure sending mail” and smtpException was unhandled”. I belive this is because the company I am doing this for has a network proxy. I can access the internet. I just can not send an email. Is there anything I need to add to allow it to send it through the proxy?
Here is the error:

    System.Net.Mail.SmtpException was unhandled
  Message=Failure sending mail.
  Source=System
  StackTrace:
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\DavidPaquette\My Documents\Visual Studio 2010\Projects\TestMail\TestMail\Form1.cs:line 47
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at WindowsFormsApplication1.Program.Main() in C:\Documents and Settings\DavidPaquette\my documents\visual studio 2010\Projects\TestMail\TestMail\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Net.WebException
       Message=Unable to connect to the remote server
       Source=System
       StackTrace:
            at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
            at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
            at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
            at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
            at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
            at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
            at System.Net.Mail.SmtpClient.GetConnection()
            at System.Net.Mail.SmtpClient.Send(MailMessage message)
       InnerException: System.Net.Sockets.SocketException
            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 173.194.70.108:587
            Source=System
            ErrorCode=10060
            NativeErrorCode=10060
            StackTrace:
                 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
                 at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
            InnerException: 

And here is the email portion of the code:

MailMessage message = new MailMessage();

    message.To.Add(new MailAddress("email@gmail.com"));
    message.From = new MailAddress("email@gmail.com");
    //Attachment attachment = new Attachment(FileUpload1.PostedFile.FileName);
    message.Subject = "Subject";
    message.Body = "This is a test"; 

    //message.Attachments.Add(attachment);     
    SmtpClient client = new SmtpClient();

    client.Port = 587; // Gmail works on this port   
    client.Host = "smtp.gmail.com";   
    System.Net.NetworkCredential nc = new System.Net.NetworkCredential("email@gmail.com", "pass"); 
    client.EnableSsl = true;     
    client.UseDefaultCredentials = false;  
    client.Credentials = nc;  
    client.Send(message);   

Here are the includes:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Net;
using System.Collections;
using System.Text.RegularExpressions;
using System.Net.Mail;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:03:41+00:00Added an answer on June 8, 2026 at 1:03 pm

    You can add a proxy server to your web.config file, http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx

    <configuration>
      <system.net>
        <defaultProxy>
          <proxy
            usesystemdefault="true"
            proxyaddress="http://192.168.1.10:3128"
            bypassonlocal="true"
          />
          <bypasslist
            <add address="[a-z]+\.contoso\.com" />
          </bypasslist>
        </defaultProxy>
      </system.net>
    </configuration>
    

    Once you have added this and configured it all outgoing calls (to your SMTP server) will go through the proxy server (unless you add it to the bypass list…).

    /Viktor

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a program that finds out how many months they
So I am trying to create a program that tracks gps coordinates and then
I am trying to create a program that will get data directly from socket
I am trying to create a program that will be passed input data from
I'm trying to create a program that takes a text file of c++ code
I am trying to create a program that will do some simple calculations, but
I am trying to create a program that has one tableview and when you
I'm currently trying to create a program that estimates location based on signal strength.
I'm trying to create a c program that implements the radon transform algorithm. I
I am trying to create a Jenkins job that restarts a program that runs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.