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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:18:14+00:00 2026-05-27T09:18:14+00:00

I’m trying to fill a queue with user’s mails to send confirmation mails to

  • 0

I’m trying to fill a queue with user’s mails to send confirmation mails to them after a period of time, so every time any user fill his registration form I add him to the queue in order to send mails to them after about one minute and here is my code

public static class Gmail
    {
        private static int ? date;
        public static bool SendMail(string AdminMail,string AdminPassword,string subject,string toAddress, string content,DateTime SendTime)
        {
            var toAddressList = new Queue<string>();
            toAddressList.Enqueue(toAddress);
            if(date==null)
            {
                date = DateTime.Now.Second;
            }
            if (date-SendTime.Second > 120)
            {
                    var message = new MailMessage
                                      {
                                          From = new MailAddress(AdminMail)
                                      };

                    foreach (var toAddressl in toAddressList)
                    {
                        message.To.Add(new MailAddress(toAddressl));
                    }

                    message.Subject = subject;
                    message.Body = content;
                    message.IsBodyHtml = true;
                    var smtp = new SmtpClient
                                   {
                                       Credentials = new System.Net.NetworkCredential(AdminMail, AdminPassword),
                                       Port = 587,
                                       Host = "smtp.gmail.com",
                                       EnableSsl = true
                                   };
                    smtp.Send(message);
                //date = SendTime;
                return true;
            }
            return false;
        }
    }

but actually what happens is that the queue starts from zero every time, so it is only filled with the mail of the current registered users and never contain the mails of the previous registered users which I want them to exist as I will send mails to all mails existing in the queue.So I’m wondering how I can prevent the queue from been cleared when the page loads.Any ideas??

  • 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-27T09:18:15+00:00Added an answer on May 27, 2026 at 9:18 am

    toAddress is defined with the scope of the static method. It will only exist for the duration of that method call. That’s why it’s always 0.

    You could push it up to be a static field or property (i.e. alongside your date property) but you are still going to have issues with this; for example, what if the app pool is recycled or the website restarts? You are going to lose everything in the queue.

    A more robust design would involve storing this information in a database and running a scheduled check against those records that were recently added and don’t have a “confirm email sent” column value set, for example.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

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.