我正在使用dotnet框架发送电子邮件.这是我用来创建消息的模板:
Date of Hire: %HireDate%
Annual Salary: %AnnualIncome%
Reason for Request: %ReasonForRequest%
Name of Voluntary Employee: %FirstName% %LastName%
Total Coverage Applied For: %EECoverageAmount%
Guaranteed Coverage Portion: %GICoveragePortion%
Amount Subject to Medical Evident: %GIOverage%
Run Code Online (Sandbox Code Playgroud)
在Outlook中收到消息时,outlook告诉我"此消息中的额外换行符已被删除".消息显示如下:
Date of Hire: 9/28/2001
Annual Salary: $100,000
Reason for Request: New Hire
Name of Voluntary Employee: Ronald Weasley Total Coverage Applied For: $500,000 Guaranteed Coverage Portion: $300,000.00 Amount Subject to Medical Evident: $200,000
Run Code Online (Sandbox Code Playgroud)
请注意Outlook如何在名称,EECoverageAmount等之后错误地删除所需的换行符...
对于电子邮件接收者来说,获取格式正确的电子邮件非常重要,我必须假设其中一些使用outlook 2003.我也不能假设他们知道足以关闭autoclean功能以使消息正确格式化.
我在其他邮件客户端中查看了这些邮件并正确显示
更多信息:
问题:如何更改邮件格式以避免此问题?
在HTML中保留空格的最佳方法是什么?我们有很多页面会从我们的数据库中删除数据,并且数据中可能包含多个空格.保存数据的呈现HTML元素与锚标记不同(<a>), spans (<span>), table rows (<tr>, <td>, etc.
现在最容易做的就是添加一个像这样的全局css类:
body a, span, tr, td { white-space: pre; }
Run Code Online (Sandbox Code Playgroud)
我想知道是否有更好的方法来实现它,而无需为每个单独的HTML元素分配一个类.
我面临一个问题,即我的所有文本电子邮件都被压缩在一起,并且在发送过程中没有新行持续存在。
这是代码:
def send_ses_message(email_to, subject, body):
ses = init_ses_internal()
if ses:
ses.send_email(
Source='no-reply@domain.com',
Destination={
'ToAddresses': [
email_to,
],
},
Message={
'Subject': {
'Data': subject,
},
'Body': {
'Text': {
'Data': body,
'Charset': 'UTF-8',
},
'Html': {
'Data': body,
'Charset': 'UTF-8',
},
}
},
ReplyToAddresses=[
'mharris@domain.com', # just in case someone replies to a no-reply@ address I'll receive them
],
ReturnPath='mharris@domain.com', # bounce backs will come to me also
)
return True
Run Code Online (Sandbox Code Playgroud)
我最近尝试强制使用 UTF-8,希望可以让换行符持续存在。之后,我在应该存在新行的地方添加了 \n 。
以下是电子邮件的示例:
def send_reset_email(self, email_to, unique_id): …Run Code Online (Sandbox Code Playgroud) 我的电子邮件内容文本是
String text = "Hey, You are create a new Account! Best, MyTeam";
Run Code Online (Sandbox Code Playgroud)
如何将文本格式化为:
嘿, 您正在创建一个新帐户! 最好的,我的团队
我正在使用MailMessage和SmtpClient从ASP.NET发送电子邮件.我想介绍一些换行符,但没有以下工作:
sbBody.Append("<table width='100%'><tr><td></br></br>");sbBody.Append("<table width='100%'><tr><td>\r\n\r\n");sbBody是一个StringBuilder,我最后用它来设置MailMessage的主体: mailMessage.Body = sbBody.ToString()
我在这里失踪了什么?我在Outlook中查看电子邮件,当然我将IsBodyHtml设置为true.
谢谢你的时间.
编辑:解决了,这是一个语法错误,</br>而不是<br/>