|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
mail failedI use dotnet 2005 and c sharp to deliever a mail to a certain mail address,but it failed with messages such as "invalid parameter,the server response: decode failed". My codes is listed belowed: try { MailMessage mailObj = new MailMessage(); mailObj.To.Add("wuhua***@hotmail.com"); mailObj.From = new MailAddress(crespo1***@21cn.com); mailObj.Subject = "Óʼþ²âÊÔ"; mailObj.Body = "ºÍѶÓʼþ½ÓÊÕ²âÊԳɹ¦! "; mailObj.IsBodyHtml = true; mailObj.Priority = MailPriority.High; mailObj.BodyEncoding = System.Text.Encoding.UTF8; System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.21cn.com"); client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("crespo1***@21cn.com", this.tb_mailUserPassword.Text); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Send(mailObj); } catch(Exception ex) { MessageBox.Show(ex.Message.ToString()); return; } crespo1***@21cn.com is a correct account of mail.21cn.com,Could anyone help me? Crespo 2006-06-30 see answer in microsoft.public.dotnet.languages.csharp
-- Show quote--- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "Crespo" <wuhua***@21cn.com> wrote in message news:eCkAQA$mGHA.3544@TK2MSFTNGP05.phx.gbl... > hi,everybody > I use dotnet 2005 and c sharp to deliever a mail to a certain mail > address,but it failed with messages such as "invalid parameter,the server > response: decode failed". My codes is listed belowed: > try > { > MailMessage mailObj = new MailMessage(); > mailObj.To.Add("wuhua***@hotmail.com"); > mailObj.From = new MailAddress(crespo1***@21cn.com); > > mailObj.Subject = "Óʼþ²âÊÔ"; > mailObj.Body = "ºÍѶÓʼþ½ÓÊÕ²âÊԳɹ¦! "; > > mailObj.IsBodyHtml = true; > mailObj.Priority = MailPriority.High; > mailObj.BodyEncoding = System.Text.Encoding.UTF8; > > System.Net.Mail.SmtpClient client = new > System.Net.Mail.SmtpClient("smtp.21cn.com"); > client.UseDefaultCredentials = false; > > client.Credentials = new > System.Net.NetworkCredential("crespo1***@21cn.com", > this.tb_mailUserPassword.Text); > client.DeliveryMethod = SmtpDeliveryMethod.Network; > > client.Send(mailObj); > > } > catch(Exception ex) > { > MessageBox.Show(ex.Message.ToString()); > return; > } > > crespo1***@21cn.com is a correct account of mail.21cn.com,Could anyone > help me? > > > Crespo > 2006-06-30 > > > Thanks for your answer. But following your advice,I set the
mailObj.IsBodyHtml as false and mailObj.BodyEncoding as System.Text.Encoding.ASCII,it still failed with the same error message,Could you further explain for me? Crespo "Nick Malik [Microsoft]" <nickmalik@hotmail.nospam.com> дÈëÏûÏ¢ see answer in microsoft.public.dotnet.languages.csharpnews:lrKdnfF4TPCOdTnZnZ2dnUVZ_t6dnZ2d@comcast.com... -- Show quote--- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- "Crespo" <wuhua***@21cn.com> wrote in message news:eCkAQA$mGHA.3544@TK2MSFTNGP05.phx.gbl... > hi,everybody > I use dotnet 2005 and c sharp to deliever a mail to a certain mail > address,but it failed with messages such as "invalid parameter,the server > response: decode failed". My codes is listed belowed: > try > { > MailMessage mailObj = new MailMessage(); > mailObj.To.Add("wuhua***@hotmail.com"); > mailObj.From = new MailAddress(crespo1***@21cn.com); > > mailObj.Subject = "Óʼþ²âÊÔ"; > mailObj.Body = "ºÍѶÓʼþ½ÓÊÕ²âÊԳɹ¦! "; > > mailObj.IsBodyHtml = true; > mailObj.Priority = MailPriority.High; > mailObj.BodyEncoding = System.Text.Encoding.UTF8; > > System.Net.Mail.SmtpClient client = new > System.Net.Mail.SmtpClient("smtp.21cn.com"); > client.UseDefaultCredentials = false; > > client.Credentials = new > System.Net.NetworkCredential("crespo1***@21cn.com", > this.tb_mailUserPassword.Text); > client.DeliveryMethod = SmtpDeliveryMethod.Network; > > client.Send(mailObj); > > } > catch(Exception ex) > { > MessageBox.Show(ex.Message.ToString()); > return; > } > > crespo1***@21cn.com is a correct account of mail.21cn.com,Could anyone > help me? > > > Crespo > 2006-06-30 > > > Thanks for your attention. In fact,my first code works well when I specify
some certain smtp servers,but doesn't work well over others which are even correct smtp servers. Thank you very much anyway. Crespo Show quote "Crespo" <wuhua***@21cn.com> дÈëÏûÏ¢ news:uD7Lz0TnGHA.1244@TK2MSFTNGP05.phx.gbl... > Thanks for your answer. But following your advice,I set the > mailObj.IsBodyHtml as false and mailObj.BodyEncoding as > System.Text.Encoding.ASCII,it still failed with the same error message,Could > you further explain for me? > > Crespo > "Nick Malik [Microsoft]" <nickmalik@hotmail.nospam.com> дÈëÏûÏ¢ > news:lrKdnfF4TPCOdTnZnZ2dnUVZ_t6dnZ2d@comcast.com... > see answer in microsoft.public.dotnet.languages.csharp > > -- > --- Nick Malik [Microsoft] > MCSD, CFPS, Certified Scrummaster > http://blogs.msdn.com/nickmalik > > Disclaimer: Opinions expressed in this forum are my own, and not > representative of my employer. > I do not answer questions on behalf of my employer. I'm just a > programmer helping programmers. > -- > "Crespo" <wuhua***@21cn.com> wrote in message > news:eCkAQA$mGHA.3544@TK2MSFTNGP05.phx.gbl... > > hi,everybody > > I use dotnet 2005 and c sharp to deliever a mail to a certain mail > > address,but it failed with messages such as "invalid parameter,the server > > response: decode failed". My codes is listed belowed: > > try > > { > > MailMessage mailObj = new MailMessage(); > > mailObj.To.Add("wuhua***@hotmail.com"); > > mailObj.From = new MailAddress(crespo1***@21cn.com); > > > > mailObj.Subject = "Óʼþ²âÊÔ"; > > mailObj.Body = "ºÍѶÓʼþ½ÓÊÕ²âÊԳɹ¦! "; > > > > mailObj.IsBodyHtml = true; > > mailObj.Priority = MailPriority.High; > > mailObj.BodyEncoding = System.Text.Encoding.UTF8; > > > > System.Net.Mail.SmtpClient client = new > > System.Net.Mail.SmtpClient("smtp.21cn.com"); > > client.UseDefaultCredentials = false; > > > > client.Credentials = new > > System.Net.NetworkCredential("crespo1***@21cn.com", > > this.tb_mailUserPassword.Text); > > client.DeliveryMethod = SmtpDeliveryMethod.Network; > > > > client.Send(mailObj); > > > > } > > catch(Exception ex) > > { > > MessageBox.Show(ex.Message.ToString()); > > return; > > } > > > > crespo1***@21cn.com is a correct account of mail.21cn.com,Could anyone > > help me? > > > > > > Crespo > > 2006-06-30 > > > > > > > |
|||||||||||||||||||||||