//DA QUI IL MIO CODICE PERSONALIZZATO //GENERALI //Codice per permettere l'avvio dell'app Posta e inviare mail private async void ComposeEmail(Windows.ApplicationModel.Contacts.Contact recipient, string messageBody, StorageFile attachmentFile) { var emailMessage = new Windows.ApplicationModel.Email.EmailMessage(); emailMessage.Body = messageBody; if (attachmentFile != null) { var stream = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(attachmentFile); var attachment = new Windows.ApplicationModel.Email.EmailAttachment( attachmentFile.Name, stream); emailMessage.Attachments.Add(attachment); } var email = recipient.Emails.FirstOrDefault <Windows.ApplicationModel.Contacts.ContactEmail>(); if (email != null) { var emailRecipient = new Windows.ApplicationModel.Email.EmailRecipient(email.Address); emailMessage.To.Add(emailRecipient); } await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(emailMessage); }
private async void SendEmail(Contact toRecipient, string messageBody) { var to = toRecipient.Emails.FirstOrDefault <Windows.ApplicationModel.Contacts.ContactEmail>(); var emailRecipient = new Windows.ApplicationModel.Email.EmailRecipient(to.Address, toRecipient.FullName); EmailMessage objEmail = new EmailMessage(); objEmail.Subject = "Send Email Using UWP APP"; objEmail.Body = messageBody; objEmail.To.Add(emailRecipient); await EmailManager.ShowComposeNewEmailAsync(objEmail); }
/// <summary> /// 发送邮件函数 /// </summary> /// <param name="recipient"></param> /// <param name="subject"></param> /// <param name="messageBody"></param> /// <returns></returns> private async Task ComposeEmail(Windows.ApplicationModel.Contacts.Contact recipient, string subject, string messageBody) { var emailMessage = new Windows.ApplicationModel.Email.EmailMessage(); emailMessage.Body = messageBody; var email = recipient.Emails.FirstOrDefault <Windows.ApplicationModel.Contacts.ContactEmail>(); if (email != null) { var emailRecipient = new Windows.ApplicationModel.Email.EmailRecipient(email.Address); emailMessage.To.Add(emailRecipient); emailMessage.Subject = subject; } await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(emailMessage); }
private async void Email_Click(object sender, RoutedEventArgs e) { if (App.setting.ContainsKey("email")) { string result; App.setting.TryGetValue("email", out result); string messageBody = String.Empty; foreach (string s in itemList) { messageBody = String.Concat(messageBody, s, "\n"); } var emailMessage = new Windows.ApplicationModel.Email.EmailMessage(); emailMessage.Body = messageBody; var emailRecipient = new Windows.ApplicationModel.Email.EmailRecipient(result); emailMessage.To.Add(emailRecipient); emailMessage.Subject = "BuyList"; await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(emailMessage); } }
public override void sendMessage(_nArrayAdapter<object> n1, java.lang.String n2, messaging.Message n3) { string subject = toCSharp(n2); var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); Contact recipient = contactPicker.PickContactAsync().AsTask().ConfigureAwait(false).GetAwaiter().GetResult(); if (recipient != null) { IList<ContactEmail> fields = recipient.Emails; if (fields.Count > 0) { if (fields[0].GetType() == typeof(ContactEmail)) { foreach (ContactEmail email in fields as IList<ContactEmail>) { EmailMessage emailMessage = new EmailMessage(); emailMessage.Body = toCSharp((java.lang.String)n3.getContent()); ; emailMessage.Subject = subject; var emailRecipient = new Windows.ApplicationModel.Email.EmailRecipient(email.Address); emailMessage.To.Add(emailRecipient); EmailManager.ShowComposeNewEmailAsync(emailMessage).AsTask().ConfigureAwait(false).GetAwaiter().GetResult(); break; } } } else { //OutputTextBlock.Text = "No recipient emailid Contact found"; } } else { // OutputTextBlock.Text = "No recipient emailid Contact found"; } }