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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:52:43+00:00 2026-05-27T10:52:43+00:00

I have a small email application that lets a user build a message from

  • 0

I have a small email application that lets a user build a message from checkboxes and then send the message as an email. I am trying to add an image to the email, i.e. a logo or signature. The application worked fine but as I was reseaching getting the images into the email, I found that I should be using System.Net.Mail instead of Interop. So I changed my email class to the code below. Now I’m not recieving the emails. I’m assumeing this is because the code is set-up for a server and I just want to run this on my local machine. This is just something I’m playing with to help me understand some concepts so real world use is not going to be a factor. I just want to be able to test my little program on my Outlook email account locally. My code is as follows…

using System;
using System.Net.Mail;
using System.Net.Mime;

namespace Email_Notifier  
{
    public class EmailSender:Notification
    {
        string emailRecipient = System.Configuration.ConfigurationManager.AppSettings    ["emailRecipient"];

        public void SendMail(string message)
        {
            try
            {
                string strMailContent = message;
                string fromAddress = "MyApp@gmail.com";
                string toAddress = emailRecipient;
                string contentId = "image1";
                string path = (@"C:Libraries/Pictures/Logo.gif");  

                MailMessage mailMessage = new MailMessage(fromAddress, toAddress);
                mailMessage.Subject = "Email Notification";

                LinkedResource logo = new LinkedResource( path , MediaTypeNames.Image.Gif);
                logo.ContentId = "Logo";
                // HTML formatting for logo
                AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><body><img src=cid:Logo/><br></body></html>" + strMailContent, null, MediaTypeNames.Text.Html);
                av1.LinkedResources.Add(logo);

                mailMessage.AlternateViews.Add(av1);
                mailMessage.IsBodyHtml = true;
                SmtpClient mailSender = new SmtpClient("localhost"); 
                mailSender.Send(mailMessage);
            }

            catch (Exception e)
            {
                Console.WriteLine("Problem with email execution. Exception caught: ", e);
            }
            return;
        }
    }
}
  • 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-27T10:52:43+00:00Added an answer on May 27, 2026 at 10:52 am

    You specify mailSender = new SmtpClient("localhost");.

    Have you set up an SMTP server on your local machine? If not, you will need to do so to use SmtpClient. Otherwise, specify a hostname other than localhost, perhaps using your Gmail account as specified here, bearing in mind you will need to configure it for authentication and SSL.

    See also the documentation for SmtpClient.

    There are also one or two other issues I can see with your code – but let’s deal with these after getting simple mail sending working.

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

Sidebar

Related Questions

I have an small ASP.NET application that reads data from a table and sends
i am trying to build a small email worker that sends my emails. The
I have a small script that I wrote to send an email out to
I have a small job that takes a text file of email/zip codes and
I have small web app that generate PDF files as a report. I'm trying
I have a small WinForms application that sends notification emails. It works fine with
I have a web based email application that logs me out after 10 minutes
I have a small application which reads from a Oracle 9i database and sends
I have a small application written in c# as a console app that I
I have created a small daemon (basically a console application that hides the console

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.