'보낸 사람'확인 전자 메일 주소로 사용해야하는 다음 문자열이 있습니다. 이것은 웹 클라이언트에서 볼 때 문제를 일으키는 스페인어 번역입니다. 아래에 표시됩니다. 값이된다 이메일 클라이언트 내에서전자 메일 주소 인코딩 문제
<data name="BookingConfirmation_FromAddress" xml:space="preserve">
<value>Confirmació[email protected]</value>
</data>
아래와 같이 리소스 문자열에서 촬영
model.FromAddresses = new EmailAddress
{
Address = fromAddressComponents[0],
DisplayName = fromAddressComponents[1]
};
값은, (Confirmació[email protected]을해야한다)
=?utf-8?Q?Confirmaci=C3=B3n
를 어떻게 볼 수 이걸 피하려면? 나는 그것 때문에 알지만, 나는이 문제를 피하는 방법을 모르겠습니다!
감사합니다,
UPDATE
전체 코드 아래 제임스 :
public void Send(MailAddress to, MailAddress from, string subject, string body)
{
var message = new MailMessage
{
BodyEncoding = new System.Text.UTF8Encoding(true),
From = from,
Subject = subject,
Body = body,
IsBodyHtml = true
};
message.To.Add(to.Address);
var smtp = new SmtpClient() { Timeout = 100000 };
try
{
smtp.Send(message);
}
finally
{
if (smtp.DeliveryMethod == SmtpDeliveryMethod.Network)
smtp.Dispose();
}
}
// New Version
// --------------------------
public override void Handle(SendEmailEmailCommand emailCommand)
{
if(!_config.SendEmail)
{
return;
}
var to = new MailAddress(emailCommand.To.Address, emailCommand.To.DisplayName);
var from = new MailAddress(emailCommand.From.Address, Uri.UnescapeDataString(emailCommand.From.DisplayName));
try
{
var msgBody = _compressor.Decompress(emailCommand.Body);
_emailClient.Send(to, from, emailCommand.Subject, msgBody);
}
catch (Exception ex)
{
_logger.Error("An error occurred when trying to send an email", ex);
throw;
}
}
public void Send(MailAddress to, MailAddress from, string subject, string body)
{
var message = new MailMessage
{
BodyEncoding = new System.Text.UTF8Encoding(true),
From = from,
Subject = subject,
Body = body,
IsBodyHtml = true
};
message.To.Add(to.Address);
if (!string.IsNullOrWhiteSpace(_config.BccEmailRecipents))
{
message.Bcc.Add(_config.BccEmailRecipents);
}
SendEmail(message);
if (_config.BackupEmailsEnabled)
{
SendBackupEmail(message);
}
}
private void SendEmail(MailMessage message)
{
var smtp = new SmtpClient() { Timeout = 100000 };
try
{
smtp.Send(message);
}
finally
{
if (smtp.DeliveryMethod == SmtpDeliveryMethod.Network)
smtp.Dispose();
}
}
감사합니다. ecncode/decode를 시도했지만 작동하지 않았습니다. –
리소스 문자열에서 값을 가져 오는 방법을 코드에 표시 할 수 있습니까 ??? –
실제로 유효한 전자 메일 주소입니까? –