开发者

"Exception: Process timed out" during sending mail in C# windows .net

开发者 https://www.devze.com 2023-02-06 22:27 出处:网络
when i am sending mail i am getting an exception \"Timed out\". How will i solve this ? My code is below..

when i am sending mail i am getting an exception "Timed out". How will i solve this ? My code is below.. // To MailMessage sendmail = new MailMessage();

            for (int k = 0; k < globaldecl.application1.filecount开发者_开发百科; k++)
            {
                string fil = attachfile[k];
                Attachment data = new Attachment(fil); // Attaching multiples  files 

                sendmail.Attachments.Add(data);
            }

            sendmail.To.Add(sendfrom);
            sendmail.IsBodyHtml = true;
            // From
            MailAddress mailAddress = new MailAddress(sendfrom, textmessagefromvalue.Text);

            sendmail.From = mailAddress;

            // Subject and Body

            if(textBoxsubject.Text != "")
                sendmail.Subject = textBoxsubject.Text;



            if(textBoxadcc.Text!="")
                sendmail.CC.Add(textBoxadcc.Text);
            if(textBoxaddbcc.Text != "")
                sendmail.Bcc.Add(textBoxaddbcc.Text);


            sendmail.Body = MailText.Text;
            sendmail.ReplyTo = mailAddress;


            // Init SmtpClient and send
           SmtpClient smtpClient = new SmtpClient(sendfromsmtp, sendfromport);

            System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(sendfrom,sendfrompassword);
            smtpClient.Credentials = credentials;


            smtpClient.Send(sendmail);

and i am getting exception "The Operation has Timed Out".

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号