UWP 电子邮件消息换行符/换行符

本文关键字:换行符 消息 电子邮件 UWP | 更新日期: 2023-09-27 17:56:51

我正在寻找一种在 UWP 应用中的EmailMessage()正文中添加换行符的方法。

我已经尝试过使用"'n"'r'nEnvironment.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);
    }

UWP 电子邮件消息换行符/换行符

我正在显示这样的电子邮件,它在正文中将其分成两行

 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 中发送电子邮件的同一篇文章。您发布的代码看起来与它相同。这个例子很糟糕,而且是错误的。我发布的方式效果更好。