Click here to Skip to main content
15,891,848 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I implemented code to send email and its working fine.But the same not works for sometimes.
why like this happening.why the code is not working
Any solution for this problem

please check my code


C#
System.Net.Mail.MailMessage msgMail = new System.Net.Mail.MailMessage("xxxx@xxxxx.com", txtEmail.Text);

       string mailid = "xxxx@bexxxx.com";
       string Pasword = xxxxx;

       string msg = null;
       string mTo = To;
       string mFrom = mailid;


       msgMail.Subject = Registration Confirmation;
       System.Text.StringBuilder SB = new System.Text.StringBuilder();
       System.IO.StringWriter Sw = new System.IO.StringWriter(SB);


       string mMsg = "hi"

       mMsg = mMsg + SB.ToString();

       try
       {
           msgMail.To.Add(mTo);
           msgMail.From = new System.Net.Mail.MailAddress(mFrom);
           msgMail.IsBodyHtml = true;
           msgMail.Body = mMsg;
           msgMail.Priority = System.Net.Mail.MailPriority.High;
           System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
           smtp.Host = "mymail.brinkster.com";
           smtp.Port = 25;
           smtp.Credentials = new System.Net.NetworkCredential(mFrom, Pasword);
           smtp.EnableSsl = true;

           smtp.Send(msgMail);

       }


Thanks in Advance
Amrutha
Posted
Updated 1-Feb-12 23:51pm
v3
Comments
OriginalGriff 2-Feb-12 4:28am    
Since we can't see your screen, read your HDD or your mind, we can't answer.
We need to know what code you are using, when it goes wrong, what heppens when it goes wrong, and any other relevant information.
Use the "Improve question" widget to edit your question and provide better information.
Anuja Pawar Indore 2-Feb-12 4:47am    
Use Improve question link and add your code there
Sergey Alexandrovich Kryukov 2-Feb-12 4:30am    
Griff is very modest here. He has some access to your hard drive, but not at this phase of the Moon, that's why he requested some more information. Just imagine how it would be possible to help you.
--SA
OriginalGriff 2-Feb-12 4:58am    
I just can't take off the tin-foil hat at this time of month, or The Voices start again.
And we all remember what happened last time, don't we? :sigh:
André Kraak 2-Feb-12 4:54am    
Moved the code from the solution to the question and removed the solution.

Please to do not post additions to your question as a solution. If you wish to change your question use the Improve Question button.
Using an solution like this will give the people the impression that your question has been answered and perhaps not look at it, causing you not to get an answer to your question.

1 solution

Check my answer Here
error in asp.net code to send email[^]

Thanks
--RA
 
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