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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:23:57+00:00 2026-05-16T12:23:57+00:00

I am using mail message class to send an email. But if i check

  • 0

I am using mail message class to send an email. But if i check my Gmail account, mail is received as separate mail. I want mails in a single thread. I am also using the same subject and tried appending “Re: ” before subject. it did not work for me.
I will be pleased if get the solution. following is the code I am using.

public static bool SendEmail(
    string pGmailEmail,
    string pGmailPassword,
    string pTo,
    string pFrom,
    string pSubject,
    string pBody,
    System.Web.Mail.MailFormat pFormat,
    string pAttachmentPath)
    {
        try
        {
            System.Web.Mail.MailMessage myMail = new System.Web.Mail.MailMessage();
            myMail.Fields.Add
                ("http://schemas.microsoft.com/cdo/configuration/smtpserver",
                              "smtp.gmail.com");
            myMail.Fields.Add
                ("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
                              "465");
            myMail.Fields.Add
                ("http://schemas.microsoft.com/cdo/configuration/sendusing",
                              "2");
            //sendusing: cdoSendUsingPort, value 2, for sending the message using
            //the network.

            //smtpauthenticate: Specifies the mechanism used when authenticating
            //to an SMTP
            //service over the network. Possible values are:
            //- cdoAnonymous, value 0. Do not authenticate.
            //- cdoBasic, value 1. Use basic clear-text authentication.
            //When using this option you have to provide the user name and password
            //through the sendusername and sendpassword fields.
            //- cdoNTLM, value 2. The current process security context is used to
            // authenticate with the service.
            myMail.Fields.Add
            ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            //Use 0 for anonymous
            myMail.Fields.Add
            ("http://schemas.microsoft.com/cdo/configuration/sendusername",
                pGmailEmail);
            myMail.Fields.Add
            ("http://schemas.microsoft.com/cdo/configuration/sendpassword",
                 pGmailPassword);
            myMail.Fields.Add
            ("http://schemas.microsoft.com/cdo/configuration/smtpusessl",
                 "true");
            myMail.From = pFrom;
            myMail.To = pTo;
            myMail.Subject = pSubject;
            myMail.BodyFormat = pFormat;
            myMail.Body = pBody;
            if (pAttachmentPath.Trim() != "")
            {
                MailAttachment MyAttachment =
                        new MailAttachment(pAttachmentPath);
                myMail.Attachments.Add(MyAttachment);
                myMail.Priority = System.Web.Mail.MailPriority.High;
            }

            // System.Web.Mail.SmtpMail.SmtpServer = CCConstants.MAIL_SERVER;
            System.Web.Mail.SmtpMail.Send(myMail);
            return true;
        }
        catch
        {
            throw;
        }
    }
  • 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-16T12:23:58+00:00Added an answer on May 16, 2026 at 12:23 pm

    you should know thread starter email internal ID, then you should send it back via headers “In-Reply-To: ” or “References: “.
    Btw sending email via gmail is rather simple:

    var smtpClient = new SmtpClient("smtp.gmail.com",587);
    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtpClient.EnableSsl = true;
    smtpClient.UseDefaultCredentials = false;
    smtpClient.Credentials = new NetworkCredential("USERNAME@gmail.com"
                ,"PASSWORD");
    using (MailMessage message = new MailMessage("USERNAME@gmail.com","USERNAME@gmail.com"))
    {
        message.Subject = "test";
        smtpClient.Send(message);
    }
    
    using (MailMessage message = new MailMessage("USERNAME@gmail.com","USERNAME@gmail.com"))
    {
        message.Subject = "Re: test";
        message.Headers.Add("In-Reply-To", "<MESSAGEID.From.Original.Message>");
        message.Headers.Add("References",  "<MESSAGEID.From.Original.Message>");
        smtpClient.Send(message);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send an email message using the .NET MailMessage class which can
How can I send an email using SYstem.Net.Mail to an email address that is
I am using Zend_Mail to send an email of a log file, but it
I have an application that uses SmtpClient to send E-Mail, but the E-Mails are
Sending a message from the Unix command line using mail TO_ADDR results in an
What is the simplest way to send mail using Ruby on Rails? Is there
Hi I'm using System.Net.Mail to send some HTML formatted emails. What is the correct
I have an App that will send authenticated emails using System.Net.Mail and System.Net.NetworkCredential my
Using the obsolete System.Web.Mail sending email works fine, here's the code snippet: Public Shared
i'm using drupal 6 and tries to send an email to all users by

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.