public override async Task<bool> SendEmail(EmailData emailData)
        {
            try
            {
                var mail = new EmailMessage
                {
                    Body = String.IsNullOrWhiteSpace(emailData.MessageBody) ? "Body Message" : emailData.MessageBody,
                    Subject = String.IsNullOrWhiteSpace(emailData.Subject) ? "Subject" : emailData.MessageBody
                };
                //var EmailTasks = 
                var emailTasks = new List<Task>
                {
                    Task.Run(() => { AddEmailRecipientsToList(emailData.ToRecipients, mail.To); }),
                    Task.Run(() => { AddEmailRecipientsToList(emailData.CcRecipients, mail.CC); }),
                    Task.Run(() => { AddEmailRecipientsToList(emailData.BccRecipients, mail.Bcc); })
                };
                await Task.WhenAll(emailTasks.ToArray());
                Parallel.ForEach(emailData.Attachment, async attachment =>
                {
                    var bReferenceUrlIsOk = false;
                    if (!String.IsNullOrWhiteSpace(attachment.ReferenceUrl))
                    {

                        try
                        {
                            mail.Attachments.Add(new EmailAttachment(attachment.FileName, RandomAccessStreamReference.CreateFromFile(await WindowsPhoneUtils.GetFileFromReferenceURL(attachment.ReferenceUrl))));
                            bReferenceUrlIsOk = true;
                        }
                        catch (Exception e)
                        {
                            WindowsPhoneUtils.Log(String.Concat("Error creating email attachment from Reference URL: ", e.Message));
                        }
                    }
                    if (bReferenceUrlIsOk) return;
                    var attachmentTempFile =
                        await
                            ApplicationData.Current.TemporaryFolder.CreateFileAsync(attachment.FileName,
                                CreationCollisionOption.GenerateUniqueName);
                    mail = await CreateAttachmentObject(attachmentTempFile, attachment, mail);
                });

                if (AppverseBridge.Instance.RuntimeHandler.Webview.Dispatcher.HasThreadAccess) await EmailManager.ShowComposeNewEmailAsync(mail);
                else await AppverseBridge.Instance.RuntimeHandler.Webview.Dispatcher.RunAsync(CoreDispatcherPriority.High, async () => await EmailManager.ShowComposeNewEmailAsync(mail));
                return true;
            }
            catch (Exception ex)
            {
                WindowsPhoneUtils.Log("Error while sending Email: " + ex.Message);
                return false;
            }
        }
Exemplo n.º 2
0
 public override bool SendEmail(EmailData emailData)
 {
     UIApplication.SharedApplication.InvokeOnMainThread (delegate {
         if (MFMailComposeViewController.CanSendMail) {
             SystemLogger.Log(SystemLogger.Module.PLATFORM,"device supports email send");
             using (var pool = new NSAutoreleasePool ()) {
                 var thread = new Thread (ShowMailComposer);
                 thread.Start (emailData);
             }
             ;
         } else {
             INotification notificationService = (INotification)IPhoneServiceLocator.GetInstance ().GetService ("notify");
             if (notificationService != null) {
                 notificationService.StartNotifyAlert ("Mail Alert", "Sending of mail messages is not enabled or supported on this device.", "OK");
             }
         }
     });
     return true;
 }
Exemplo n.º 3
0
 public abstract bool SendEmail(EmailData emailData);
Exemplo n.º 4
0
 public abstract Task<bool> SendEmail(EmailData emailData);
Exemplo n.º 5
0
 public override bool SendEmail(EmailData emailData)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public abstract Task <bool> SendEmail(EmailData emailData);
Exemplo n.º 7
0
 public abstract bool SendEmail(EmailData emailData);