使用Xamarin Essentials电子邮件类,我可以这样打开默认的电子邮件应用程序
public async Task SendEmail(string subject, string body, List<string> recipients)
{
try
{
var message = new EmailMessage
{
Subject = subject,
Body = body,
To = recipients,
//Cc = ccRecipients,
//Bcc = bccRecipients
};
await Email.ComposeAsync(message);
}
catch (FeatureNotSupportedException fbsEx)
{
// Email is not supported on this device
}
catch (Exception ex)
{
// Some other exception occurred
}
}有没有可能在代码中附加一个文件?我在api中找不到任何选项。
发布于 2021-08-25 18:10:00
尝试以下代码:
var message = new EmailMessage
{
Subject = "Hello",
Body = "World",
};
var fn = "Attachment.txt";
var file = Path.Combine(FileSystem.CacheDirectory, fn);
File.WriteAllText(file, "Hello World");
message.Attachments.Add(new EmailAttachment(file));
await Email.ComposeAsync(message);https://stackoverflow.com/questions/54648745
复制相似问题