我正在寻找一种方法在我的UWP应用中将换行符放在EmailMessage()
的正文中。
我已尝试使用"\n"
,\r\n
,Environment.NewLine
,<br>
,<br />
,每次在桌面,移动设备或都。我尝试使用Outlook和Gmail。
我正在使用VS2015更新3。
感谢。
编辑:这是代码
public static async Task ComposeEmail(string address, string messageSubject, StorageFile attachmentFile)
{
var emailMessage = new EmailMessage();
emailMessage.Subject = messageSubject;
var lineBreak = Environment.NewLine;
string body = lineBreak + lineBreak + lineBreak + lineBreak + lineBreak + lineBreak + textLoader.GetString("EmailPleaseDontCut") + lineBreak + Info.GetAllInfos();
emailMessage.Body = body;
if (attachmentFile != null)
{
var stream = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(attachmentFile);
var attachment = new EmailAttachment(attachmentFile.Name, stream);
emailMessage.Attachments.Add(attachment);
}
emailMessage.To.Add(new EmailRecipient(address));
await EmailManager.ShowComposeNewEmailAsync(emailMessage);
}
答案 0 :(得分:1)
我正在展示这样一封电子邮件,并将其分为两部分
EmailMessage emailMessage = new EmailMessage()
{
Subject = "App Feedback " + Package.Current.DisplayName + " " + ApplicationServices.CurrentDevice,
Body = "First Line\r\nSecondLine"
};
emailMessage.To.Add(new EmailRecipient() { Address = "admin@DotNetRussell.com" });
await EmailManager.ShowComposeNewEmailAsync(emailMessage);
我想我读过您在UWP中发送电子邮件时所做的同一篇文章。您发布的代码看起来与它完全相同。这个例子糟透了,这是错误的。我发布的方式更好。