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 4060228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:18:41+00:00 2026-05-20T15:18:41+00:00

I am trying to use the MailMessage class to construct e-mail messages that are

  • 0

I am trying to use the MailMessage class to construct e-mail messages that are transmitted to an SMTP server for delivery using the SmtpClient class.
My email is configured on outlook through an exchange server.
I had the following doubts with regards to the above implementation:

1) What is the difference between an Exchange Server and a SMTP server?

2) In my case, my outlook is configured on an exchange server using my credentials.How do I find the SMTP address so that i am able to implement the MailMessage Class?

3) Any ideas of sending emails through the application based on the exchange server if the above implementation technique is not feasible?

I am using Visual studio 2008, framework 3.5 SP1, working on winforms application with C# as the language. Please help me clear my doubts.

EDIT

I am using the following code. It doesn’t throw any error, neither does it work. I am trying to send and email to myself bu to no avail

public static void CreateMessageWithAttachment(string server)
    {
        // Specify the file to be attached and sent.
        // This example assumes that a file named Data.xls exists in the
        // current working directory.
        string file = "data.xls";
        // Create a message and set up the recipients.
        MailMessage message = new MailMessage(
           "ben@contoso.com",
           "ben@contoso.com",
           "Quarterly data report.",
           "See the attached spreadsheet.");

        // Create  the file attachment for this e-mail message.
        Attachment data = new Attachment(file, MediaTypeNames.Application.Octet);
        // Add time stamp information for the file.
        ContentDisposition disposition = data.ContentDisposition;
        disposition.CreationDate = System.IO.File.GetCreationTime(file);
        disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
        disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
        // Add the file attachment to this e-mail message.
        message.Attachments.Add(data);

        //Send the message.
        SmtpClient client = new SmtpClient(server);
        // Add credentials if the SMTP server requires them.
        client.Credentials = CredentialCache.DefaultNetworkCredentials;

  try {
          client.Send(message);
        }
        catch (Exception ex) {
          Console.WriteLine("Exception caught in CreateMessageWithAttachment(): {0}", 
                ex.ToString() );              
        }

        data.Dispose();
    }
  • 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-05-20T15:18:42+00:00Added an answer on May 20, 2026 at 3:18 pm

    1) What is the difference between an Exchange Server and a SMTP server?

    Exchange server contains more stuff.

    2) In my case, my outlook is configured on an exchange server using my credentials.How do I find the SMTP address so that i am able to implement the MailMessage Class?

    Outlook -> Tools -> Accounts -> Edit account.

    It’s the same address as the exchange server. Port 25 is the standard SMTP port.
    Exchange might need authentication.

    3) Any ideas of sending emails through the application based on the exchange server if the above implementation technique is not feasible?

    You can’t just use MailMessage, you’ll need SmtpClient too.

    Example using Exchange: Getting a sent MailMessage into the "Sent Folder"

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

Sidebar

Related Questions

I am trying to use the System.Net.Mail.MailMessage class in C# to create an email
I'm trying to use the code below to send messages via System.Net.Mail and am
Trying to use an excpetion class which could provide location reference for XML parsing,
I'm trying to send an email from c# code via our company's exchange server.
I am trying to setup SMTP server on IIS for sending mails. The SMTP
I am trying to send an email using the following very standard code. However,
Trying to use make from cygwin using g++ I was getting Access Denied error
I am trying to query the following HQL using GORM: MailMessage.executeQuery(toId, count(toId) from (SELECT
I am trying to send an email via GMail from ASP.Net using the code
I'm trying use jquery to remove a class from an element (not knowing ahead

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.