Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi..
i write schedule email code. its working but i got multiple emails. how to remove this issue and how to send only one email..




Thanks in advance..
Posted
Comments
[no name] 1-Dec-12 1:50am    
Show your code..
OriginalGriff 1-Dec-12 2:19am    
Without your code, we can't help - it could be anything!
Use the "Improve question" widget to edit your question and provide better information.
NaniCh 1-Dec-12 3:01am    
i send the email through smtp servr. code exicute one time only.. but smtp server sends multiple emails
OriginalGriff 1-Dec-12 3:08am    
So there is a problem with your code somewhere - we can't see your screen, so you need to post the relevant code fragments.
Our only other option is to start guessing, and that is not a viable strategy in computing!
Use the "Improve question" widget to edit your question and provide better information or we can't help you!
Er. Vikas Sangal 1-Dec-12 2:43am    
check is there any loop for or foreach. post ur code

Check for the time you have fixed for sending email.

and how many time it fires.
 
Share this answer
 
hi dear,

try this code.

you are execute this code then email send one time and you are send multiple emails then use for loop.

private void MailSend()
    {
            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");  
                SmtpServer.Host = "smtp.gmail.com";

                mail.From = new MailAddress("FromMailName@gamil.com");
                mail.To.Add("ToMailName@gmail.com");
                mail.Subject = "Test Mail";
                mail.Body = "This is for testing SMTP mail from GMAIL";

                SmtpServer.Port = 587;

                SmtpServer.Credentials = new System.Net.NetworkCredential("ToMailName@gmail.com", "123456"); // User Mail Name And Mail Password
                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);              
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 
Share this answer
 
Comments
NaniCh 4-Dec-12 6:09am    
now i am using same code. but get multiple emails. i didn't understand where this problem fire...
azizulhoque.bd 4-Dec-12 6:18am    
Please explain detail " get multiple emails. "
NaniCh 6-Dec-12 0:13am    
i write the code for scheduled emails through wcf services. i call the email service in global.asax file. in this i give the time interval 60sec so my code is running every 60 sec. i get the scheduled emails time from StoredProcedure. so when the time is matched for scheduled time and current time service can be called. my loop repeats only one time but mails sends multiple times. i didn't understand what happens.. can you help me.. THanks in advance
shaikh-adil 12-Dec-12 0:06am    
+5

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