08.06.2011, 14:24 | #1 |
Участник
|
Кодировка при отправке EMail .Net
Всем привет!
Никто не сталкивался с проблемой, когда хочешь отправить письмо с сервера и указываешь кодировку koi8-r, то падает AOS? Вот примерный код: X++: try { interopPermission.assert(); //mailAddressFrom = new System.Net.Mail.MailAddress(emailTable.SenderAddr, emailTable.SenderName); If (emailTable) //BP deviation documented mailAddressFrom = new System.Net.Mail.MailAddress(emailTable.SenderAddr, emailTable.SenderName); else //BP deviation documented mailAddressFrom = new System.Net.Mail.MailAddress(_mailSenderAddr, _mailSenderName); //BP deviation documented mailAddressTo = new System.Net.Mail.MailAddress(_emailAddr); //BP deviation documented mailMessage = new System.Net.Mail.MailMessage(mailAddressFrom, mailAddressTo); //////////----> // Вот это коварное место mailMessage.set_BodyEncoding(System.Text.Encoding::GetEncoding('KOI8-R')); //Вот так получается нормально mailMessage.set_BodyEncoding(System.Text.Encoding:get_ASCII()); ///////////-----< //BP deviation documented mailMessage.set_Subject(_mailSubject); //BP deviation documented mailMessage.set_Body(_mailBody); //BP deviation documented If (_fileName) { attachmentCollection = mailMessage.get_Attachments(); //BP deviation documented attachment = new System.Net.Mail.Attachment(_fileName); attachmentCollection.Add(attachment); } //BP deviation documented smtpClient = new System.Net.Mail.SmtpClient(emailParams.SMTPRelayServerName, emailParams.SMTPPortNumber); //BP deviation documented networkCredential = new System.Net.NetworkCredential(emailParams.SMTPUserName, password); //BP deviation documented credentialCache = new System.Net.CredentialCache(); credentialCache.Add(emailParams.SMTPRelayServerName, emailParams.SMTPPortNumber, "Basic", networkCredential); smtpClient.set_Credentials(credentialCache); smtpClient.Send(mailMessage); If (_fileName) { attachmentCollection.Dispose(); attachment.Dispose(); } CodeAccessPermission::revertAssert(); } catch { infoLog.clear(lineNum); //BP deviation documented systemException = CLRInterop::getLastException(); smtpFailedRecipientsException = systemException.get_InnerException(); errorMessage = smtpFailedRecipientsException.get_Message(); isEMailSended = checkFailed(strFmt("Ошибка: %1", errorMessage)); CodeAccessPermission::revertAssert(); } |
|
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|