Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to send a scheduled remainder of stock items so that they cant track it and be remainded of the available stock

What I have tried:

C#
try
                {
                    SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                    client.EnableSsl = true;
                    client.Timeout = 10000;
                    client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.Credentials = new NetworkCredential("fromemail@gmail.com", "password");
                    MailMessage msg = new MailMessage();
                    msg.To.Add(textBox1.Text);
                    msg.From = new MailAddress("fromemail@gmail.com");
                    msg.Subject = "Requsted pasword";
                    msg.Body = "asfgeygf agfjasj igasjfv";
                    client.Send(msg);
                    MessageBox.Show("sent!");
                } try
                {
                    SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                    client.EnableSsl = true;
                    client.Timeout = 10000;
                    client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.Credentials = new NetworkCredential("fromemail@gmail.com", "password");
                    MailMessage msg = new MailMessage();
                    msg.To.Add(textBox1.Text);
                    msg.From = new MailAddress(
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
Posted
Updated 27-Jun-19 9:30am
v2
Comments
F-ES Sitecore 27-Jun-19 9:50am    
Put your code in a loop so you run it once per recipient, changing the target email address for each person. You shouldn't send email through gmail, this is ultimately going to stop working, especially if you are sending multiple emails.
Member 14511434 27-Jun-19 9:52am    
which one should i use please help
Dave Kreskowiak 27-Jun-19 10:02am    
How does your company handle email between employees now?
BillWoodruff 28-Jun-19 2:05am    
And ... what's the problem ? What errors ?

1 solution

Quote:
which one should i use please help

That isn't really a question we can answer: tt will depend on too many factors that we can't know.

The first thing to think about is "How many people am I sending to?", the second is "how often am I doing this?"
And they are important, because most "normal" email services (including ones which come with a paid hosting plan) will apply "emails per period" (hour, day, week, month) to prevent themselves being used as bulk emailers and tying up email facilities for other users of their services. What this limit is varies, so the only way to find out is to ask the supplier. But as F-ES Sitecore says: Gmail is a bad idea as it's limit is 500 emails per 24 hours regardless of how many people you email the same message, or how many times you send a different message. So send 501 messages in any 24 hour period and you will trigger the limit.

Exceed limits on any system, and your account is likely to be suspended immediately.

The next thing to do is think "who am I sending to?" If it's internal to you company, then sending to a "no reply" email address and BCC everybody else might be the simplest solution as it only needs one send (though some systems - including Google - count each recipient as a separate email and this includes To, CC, and BCC addresses).

Once you are clear with the numbers, start looking at your possible suppliers - if you are going to be getting close to any limits, you will either be looking at a bulk email sender (and paying for the privilege) or self hosting your email system.

Either way, we can't tell you what to use!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900