开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜