Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

SMTP error

$
0
0

Hallo All

I've been battling now for the last three days to get to send a email, for some reason I managed to get it to work once ever, now I only get timeout error when exception are thrown, I tried different settings etc. I'm sure about the password and username and rest of the setting, please have a look at the code below, maybe somebody can see what I'm doing wrong.

private int emailmessage()
        {
            int result = 0;

            Fixedvariables Mailing = new Fixedvariables(); //This is for future use
            string mailHost = "smtp.mail.yahoo.co.uk";
            Int32 Portnr = 25;  //Tried 495 with ssl true
            String MailFrom = "jgl1504@yahoo.co.uk";
            String MailTo = "sales@wfocus.co.za";
            String subject = "Login details from Test";
            String body = "Message will be send now";
            String Username = "jgl1504@yahoo.co.uk";
            String Password = "*******";

            SmtpClient MailSetup = new SmtpClient();
            MailSetup.Host = mailHost;
            MailSetup.Port = Portnr;
            MailSetup.Credentials = new NetworkCredential(Username,Password);
            MailSetup.EnableSsl = false;
            MailSetup.UseDefaultCredentials = false;
            MailSetup.Timeout = 20;
            MailMessage Mail = new MailMessage(MailFrom,MailTo,subject,body);
            


                     
                       
            //LabMessage.Text = MailFrom.ToString();
            
            try
            {

                MailSetup.Send(Mail);
 
            }
            catch (Exception e)
            {
                LabMessage.Text = e.Message;
                result = 1;
            }
                
                return (result);
        }




Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>