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

  • Home
  • SEARCH
  • 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 980963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:28:02+00:00 2026-05-16T04:28:02+00:00

I am have written a test console application for retrieving the data and sending

  • 0

I am have written a test console application for retrieving the data and sending mail from the message queue.My console application resides in the same
solution of my main project.In my message queue lies the mail messages.When i run my console application there is a call to
the mail sending method but the problem is mail is not getting sent.seenms that mailSettings that i have given in
web.config file is not getting applied when i am sending mail via the console applications.Because when i am sending mail directly without
the help of console application the message is getting send successfully.Also when i specify the mail setting options in the
source code itself via smtp properties mail is getting send via console applications.But i want to send the mail via console application with
the mail setting set on web.congig.

How can i overcome this problem.

Best regards.

My setting in web.config.

My code for sending mails

public static void SendMailMessage(string from, string to, string bcc, string cc, string subject, string body,List attachments)
{
// Instantiate a new instance of MailMessage
MailMessage mMailMessage = new MailMessage();

        // Set the sender address of the mail message
        mMailMessage.From = new MailAddress(from);

        // Set the recepient address of the mail message
        //string[] arrEmailTo = to.Split(',');
        //foreach (string itemTo in arrEmailTo)
        //{

        //    //mMailMessage.To.Add(new MailAddress(itemTo));
        //}
        mMailMessage.To.Add(to);

        // Check if the bcc value is null or an empty string
        if ((bcc != null) && (bcc != string.Empty))
        {
            // Set the Bcc address of the mail message
            mMailMessage.Bcc.Add(new MailAddress(bcc));
        }

        // Check if the cc value is null or an empty value
        if ((cc != null) && (cc != string.Empty))
        {
            // Set the CC address of the mail message
            mMailMessage.CC.Add(new MailAddress(cc));
        }

        // Set the subject of the mail message
        mMailMessage.Subject = subject;

        //mMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
        //int Idd=BitConverter.ToInt32(Encrypt((Id.Id).ToString()),0);
        // byte[] IdHash = Encrypt((Id.Id).ToString());//generating hassh value
        //int IdHash1 = BitConverter.ToInt32(IdHash, 0);
        //passing the hash value by encoding it


        // Set the body of the mail message
        mMailMessage.Body = body;

        //include the attachments if any

        if(attachments!=null)

            foreach (string file in attachments)
            {
                Attachment aa = new Attachment(UpPath+file);
                mMailMessage.Attachments.Add(aa);
            }

        // Secify the format of the body as HTML
        mMailMessage.IsBodyHtml = true;
        // Set the priority of the mail message to normal
        mMailMessage.Priority = MailPriority.High;

        // Instantiate a new instance of SmtpClient
        SmtpClient mSmtpClient = new SmtpClient();
        mSmtpClient.EnableSsl = true;

//*********
//With these options set in the source code mail is getting sent fine
//******

        //mSmtpClient.Host = "smtp.gmail.com";
        //mSmtpClient.Port = 25;
        // Send the mail message
        //System.Net.NetworkCredential s = new System.Net.NetworkCredential("username@gmail.com", "password");
        //mSmtpClient.Credentials = s;
        //mSmtpClient.Port = 587;
        mSmtpClient.Send(mMailMessage);

//*********
//With these options set in the source code mail is getting sent fine
//******
}

Thanks in Advance

  • 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-16T04:28:03+00:00Added an answer on May 16, 2026 at 4:28 am

    Just for your testing, add an App.Config to the Console project with your mail settings.

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

Sidebar

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.