Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Evening,
I am doing Reservation Form in Windows applications using C#.net.
I send an email at reservation button click event.
My problem is at the time of reservation there is no net. after one hour internet is coming. how can i put this in waiting. is there any way to do this.
Posted
Updated 9-Jun-11 2:16am
v2
Comments
kiran pericherla 23-Apr-13 8:03am    
Hi,
can you tell me how to send email using Windows applications using C#.net.
If you don't mind can you post the code

You should just save the email to disk if there is currently no connection. Maybe you should then institute a Windows Service that polls the email folder, and then checks if there is an internet connection whenever there is any undelivered mail.

Hope this helps
 
Share this answer
 
Comments
Abhinav S 9-Jun-11 8:34am    
Good approach. My 5!
Wayne Gaylard 9-Jun-11 8:40am    
Thanks!
ajitha.pusapati 9-Jun-11 8:36am    
can u explain clearly.

Wayne Gaylard 9-Jun-11 8:48am    
I think the answer was pretty clear. Just pick a specific folder on the server that can be used for storing undelivered emails. When the application wants to send an email, it can check for an internet connection. If there is a connection, the app can simply send the email. If there is no connection then the application can serialize the email into text or such like and save the file to your specified folder. You can then create a Windows Service which runs on the server and keeps a watch on your specified folder. The service can use FileSystemWatcher Class to keep informed of when a file is created or updated in your folder. If there is any undelivered mail, then the service can keep on checking for an internet connection. Once it has a connection, then it can send all unsent emails. Hope this is clear.
Abdullatif M. Abu Al Rub 9-Jun-11 9:03am    
thats good i'll vote a 5 for that answer but do you have any sample code for doing such a thing??
Wayne is right.

However, you also need to trigger the action when Internet got connected. Unfortunately, nothing will give you notification. I suggest you create a Windows Service which detect accessibility of your e-mail server (SMPT server or whatever you use). You can do it by pinging its IP.

For this reason, you need to have a separate thread in your Service with periodically pings your server. The period will be determined by some delay in System.Threading.Thread.Sleep. For pinging, use the class System.Net.NetworkInformation.Ping. Also, you thread should stay in wait state when Internet is available. For this purpose, use the class System.Threading.EventWaitHandle. Share an instance of this class between thread. Your pinging thread should call EventWaitHandle.WaitOne in each cycle. When you detect that Internet was suddenly disconnected (by any exception in communication) in any other thread, you should call EventWaitHandle.Set on the same instance. It will wake-up the waiting pinging thread and let it start pinging.

—SA
 
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