Beispiel #1
0
        public void SendEmail(IEmailMessage email)
        {
            if (email == null)
                throw new ArgumentNullException("email");

            if (CanSendEmail)
            {
                var mail = new Windows.ApplicationModel.Email.EmailMessage
                           {
                               Subject = email.Subject, 
                               Body = email.Message
                           };

                foreach (var recipient in email.Recipients)
                {
                    mail.To.Add(new EmailRecipient(recipient));
                }
                foreach (var recipient in email.RecipientsCc)
                {
                    mail.CC.Add(new EmailRecipient(recipient));
                }
                foreach (var recipient in email.RecipientsBcc)
                {
                    mail.Bcc.Add(new EmailRecipient(recipient));
                }

                foreach (var attachment in email.Attachments.Cast<EmailAttachment>())
                {
                    mail.Attachments.Add(new Windows.ApplicationModel.Email.EmailAttachment(
                        attachment.FileName, attachment.Content));
                }

                EmailManager.ShowComposeNewEmailAsync(mail);
            }
        }
        private async void enviarEmail(object sender, RoutedEventArgs e)
        {
            
            Windows.ApplicationModel.Email.EmailMessage mail = new Windows.ApplicationModel.Email.EmailMessage();
            
            mail.Subject = TSubject.Text;
            mail.Body = Tbody.Text;
            mail.To.Add(new Windows.ApplicationModel.Email.EmailRecipient(Tto.Text, TNome.Text));
            await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(mail);
            Frame.Navigate(typeof(MainPage));

           

        }
Beispiel #3
0
        async void email(object sender, RoutedEventArgs e)
        {

            EasClientDeviceInformation CurrentDeviceInfor = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
            String OSVersion = CurrentDeviceInfor.OperatingSystem;
            String Manufacturer = CurrentDeviceInfor.SystemManufacturer;
            String SystemProductName = CurrentDeviceInfor.SystemProductName;

            Windows.ApplicationModel.Email.EmailMessage mail = new Windows.ApplicationModel.Email.EmailMessage();
            mail.Subject = "[UWP-10]反馈-年会活动抽奖";
            mail.Body = "\n\n\n生产厂商:" + Manufacturer + "\n系统名:" + SystemProductName + "\nOS版本:" + OSVersion;
            mail.To.Add(new Windows.ApplicationModel.Email.EmailRecipient("*****@*****.**", "Mukosame"));
            await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(mail);

        }
Beispiel #4
0
        static async Task PlatformComposeAsync(EmailMessage message)
        {
            if (message != null && message.BodyFormat != EmailBodyFormat.PlainText)
            {
                throw new FeatureNotSupportedException("UWP can only compose plain text email messages.");
            }

            var nativeMessage = new NativeEmailMessage();

            if (!string.IsNullOrEmpty(message?.Body))
            {
                nativeMessage.Body = message.Body;
            }
            if (!string.IsNullOrEmpty(message?.Subject))
            {
                nativeMessage.Subject = message.Subject;
            }
            Sync(message?.To, nativeMessage.To);
            Sync(message?.Cc, nativeMessage.CC);
            Sync(message?.Bcc, nativeMessage.Bcc);

            if (message?.Attachments?.Count > 0)
            {
                foreach (var attachment in message.Attachments)
                {
                    var path = FileSystem.NormalizePath(attachment.FullPath);
                    var file = attachment.File ?? await StorageFile.GetFileFromPathAsync(path);

                    var stream           = RandomAccessStreamReference.CreateFromFile(file);
                    var nativeAttachment = new NativeEmailAttachment(attachment.FileName, stream);

                    if (!string.IsNullOrEmpty(attachment.ContentType))
                    {
                        nativeAttachment.MimeType = attachment.ContentType;
                    }
                    else if (!string.IsNullOrWhiteSpace(file?.ContentType))
                    {
                        nativeAttachment.MimeType = file.ContentType;
                    }

                    nativeMessage.Attachments.Add(nativeAttachment);
                }
            }

            await EmailManager.ShowComposeNewEmailAsync(nativeMessage);
        }
Beispiel #5
0
        /// <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);
        }
Beispiel #6
0
        public virtual async Task ComposeEmail(IEmailMessage emailMessage)
        {
            if (emailMessage == null)
            {
                throw new ArgumentNullException("emailMessage", "Supplied argument 'emailMessage' is null.");
            }

            if (!CanComposeEmail)
            {
                throw new FeatureNotAvailableException();
            }

            var email = new Windows.ApplicationModel.Email.EmailMessage()
            {
            };


            await EmailManager.ShowComposeNewEmailAsync(null);
        }
Beispiel #7
0
        public virtual async Task ComposeEmail(IEmailMessage emailMessage)
        {
            if (emailMessage == null)
            {
                throw new ArgumentNullException("emailMessage", "Supplied argument 'emailMessage' is null.");
            }

            if (!CanComposeEmail)
            {
                throw new FeatureNotAvailableException();
            }

            var email = new Windows.ApplicationModel.Email.EmailMessage()
            {

            };

 
            await EmailManager.ShowComposeNewEmailAsync(null);
        }
        private async void sendEmail(object sender, RoutedEventArgs e)
        {
            var emailMessage = new Windows.ApplicationModel.Email.EmailMessage();

            Contact c = new Contact();

            c.Emails.Add(new ContactEmail()
            {
                Address = "*****@*****.**"
            });

            var email = c.Emails.FirstOrDefault <ContactEmail>();

            if (email != null)
            {
                var emailRecipient = new EmailRecipient(email.Address);
                emailMessage.To.Add(emailRecipient);
            }

            await EmailManager.ShowComposeNewEmailAsync(emailMessage);
        }
        public void SendEmail(IEmailMessage email)
        {
            if (email == null)
            {
                throw new ArgumentNullException(nameof(email));
            }

            if (CanSendEmail)
            {
                var mail = new Windows.ApplicationModel.Email.EmailMessage
                {
                    Subject = email.Subject,
                    Body    = email.Message
                };

                foreach (var recipient in email.Recipients)
                {
                    mail.To.Add(new EmailRecipient(recipient));
                }
                foreach (var recipient in email.RecipientsCc)
                {
                    mail.CC.Add(new EmailRecipient(recipient));
                }
                foreach (var recipient in email.RecipientsBcc)
                {
                    mail.Bcc.Add(new EmailRecipient(recipient));
                }

                foreach (var attachment in email.Attachments.Cast <EmailAttachment>())
                {
                    RandomAccessStreamReference streamRef = RandomAccessStreamReference.CreateFromFile(attachment.File);
                    mail.Attachments.Add(new Windows.ApplicationModel.Email.EmailAttachment(attachment.FileName, streamRef));
                }

#pragma warning disable 4014
                EmailManager.ShowComposeNewEmailAsync(mail);
#pragma warning restore 4014
            }
        }
Beispiel #10
0
        static async Task PlatformComposeAsync(EmailMessage message)
        {
            if (message != null && message.BodyFormat != EmailBodyFormat.PlainText)
            {
                throw new FeatureNotSupportedException("UWP can only compose plain text email messages.");
            }

            var nativeMessage = new NativeEmailMessage();

            if (!string.IsNullOrEmpty(message?.Body))
            {
                nativeMessage.Body = message.Body;
            }
            if (!string.IsNullOrEmpty(message?.Subject))
            {
                nativeMessage.Subject = message.Subject;
            }
            Sync(message?.To, nativeMessage.To);
            Sync(message?.Cc, nativeMessage.CC);
            Sync(message?.Bcc, nativeMessage.Bcc);

            await EmailManager.ShowComposeNewEmailAsync(nativeMessage);
        }
Beispiel #11
0
        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);
            }
        }
Beispiel #12
0
        private async void AppendContactFieldValues <T>(IList <T> fields)
        {
            if (fields.Count > 0)
            {
                if (fields[0].GetType() == typeof(ContactEmail))
                {
                    foreach (ContactEmail email in fields as IList <ContactEmail> )
                    {
                        var emailMessage = new Windows.ApplicationModel.Email.EmailMessage();
                        emailMessage.Body    = string.Format($"Navn: {zipAdresseInfo.Name} \nTelefon: {zipAdresseInfo.PhoneNumber} \nEmail: {zipAdresseInfo.Email} \nAdresse: {zipAdresseInfo.Adress} {zipAdresseInfo.HouseNr} \nPostnr & By: {zipAdresseInfo.Zip} {zipAdresseInfo.ZipCityName}"); // Brødtekst
                        emailMessage.Subject = "Dawa App Windows Phone 8.1";                                                                                                                                                                                                                       // Titel
                        var emailRecipent = new EmailRecipient(email.Address);
                        emailMessage.To.Add(emailRecipent);
                        await EmailManager.ShowComposeNewEmailAsync(emailMessage);

                        break;
                    }
                }
            }
            else
            {
            }
        }
Beispiel #13
0
        public void SendEmail(IEmailMessage email)
        {
            if (email == null)
            {
                throw new ArgumentNullException("email");
            }

            if (CanSendEmail)
            {
                var mail = new Windows.ApplicationModel.Email.EmailMessage
                {
                    Subject = email.Subject,
                    Body    = email.Message
                };

                foreach (var recipient in email.Recipients)
                {
                    mail.To.Add(new EmailRecipient(recipient));
                }
                foreach (var recipient in email.RecipientsCc)
                {
                    mail.CC.Add(new EmailRecipient(recipient));
                }
                foreach (var recipient in email.RecipientsBcc)
                {
                    mail.Bcc.Add(new EmailRecipient(recipient));
                }

                foreach (var attachment in email.Attachments.Cast <EmailAttachment>())
                {
                    mail.Attachments.Add(new Windows.ApplicationModel.Email.EmailAttachment(
                                             attachment.FileName, attachment.Content));
                }

                EmailManager.ShowComposeNewEmailAsync(mail);
            }
        }
Beispiel #14
0
        static async Task DoSendEmail(EmailMessage email)
        {
            var emailMessage = new Windows.ApplicationModel.Email.EmailMessage {
                Body = email.Message
            };

            email.Attachments.Do(async(a) =>
            {
                RandomAccessStreamReference stream;
                if (a.FilePath.IsUrl())
                {
                    stream = RandomAccessStreamReference.CreateFromUri(new Uri(a.FilePath));
                }
                else
                {
                    stream = RandomAccessStreamReference.CreateFromFile(await StorageFile.GetFileFromPathAsync(a.FilePath));
                }
                var attachmentFile = new Windows.ApplicationModel.Email.EmailAttachment(a.FileName, stream);
                emailMessage.Attachments.Add(attachmentFile);
            });

            email.Recipients.Do(r => emailMessage.To.Add(new EmailRecipient(r)));
            await EmailManager.ShowComposeNewEmailAsync(emailMessage);
        }
        private async Task HandleMessageUnprotected(MessageBase message)
        {
            this.Log("R: " + message._Source + "\r\n");

            try
            {
                if (message.Service != "SYSTEM")
                {
                    var dictionary = new Dictionary<string, string> { { "Type", message.Service } };
                    App.Telemetry.TrackEvent("MessageInfo", dictionary);
                }
            }
            catch (Exception)
            {
                // ignore telemetry errors if any
            }

            switch (message.Service)
            {
                case "SYSTEM":
                    {
                        if (message.Action.Equals("PONG"))
                        {
                            var totalRoundTrip = this.recentStringReceivedTick - this.sentPingTick;
                            App.Telemetry.TrackMetric(
                                "VirtualShieldPingPongTimeDifferenceMillisec", 
                                totalRoundTrip / TimeSpan.TicksPerMillisecond);
                        }
                        else if (message.Action.Equals("START"))
                        {
                            // reset orientation
                            DisplayInformation.AutoRotationPreferences = DisplayOrientations.None;

                            // turn off all sensors, accept buffer length
                            var switches = new SensorSwitches { A = 0, G = 0, L = 0, M = 0, P = 0, Q = 0 };
                            var sensors = new List<SensorSwitches>();
                            sensors.Add(switches);

                            this.ToggleSensors(new SensorMessage { Sensors = sensors, Id = 0 });
                        }

                        break;
                    }

                case "SMS":
                    {
                        var smsService = new Sms();
                        var sms = message as SmsMessage;

                        StorageFile attachment = null;
                        if (!string.IsNullOrWhiteSpace(sms.Attachment))
                        {
                            attachment = await StorageFile.GetFileFromPathAsync(sms.Attachment);
                        }

                        smsService.Send(sms.To, sms.Message, attachment, null);
                        break;
                    }

                case "EMAIL":
                    {
                        var email = new EmailMessage();
                        var emailMessage = message as Core.Models.EmailMessage;
                        email.Body = emailMessage.Message;
                        email.Subject = emailMessage.Subject;
                        email.To.Add(new EmailRecipient(emailMessage.To));
                        if (!string.IsNullOrWhiteSpace(emailMessage.Cc))
                        {
                            email.CC.Add(new EmailRecipient(emailMessage.To));
                        }

                        if (!string.IsNullOrWhiteSpace(emailMessage.Attachment))
                        {
                            var storageFile = await StorageFile.GetFileFromPathAsync(emailMessage.Attachment);
                            var stream = RandomAccessStreamReference.CreateFromFile(storageFile);

                            var attachment = new EmailAttachment(storageFile.Name, stream);

                            email.Attachments.Add(attachment);
                        }

                        await EmailManager.ShowComposeNewEmailAsync(email);

                        break;
                    }

                case "NOTIFY":
                    {
                        var notify = message as NotifyMessage;
                        if (string.IsNullOrWhiteSpace(notify.Action))
                        {
                            return;
                        }

                        if (notify.Action.ToUpperInvariant().Equals("TOAST"))
                        {
                            await this.SendToastNotification(notify);
                        }
                        else if (notify.Action.ToUpperInvariant().Equals("TILE"))
                        {
                            await this.SendTileNotification(notify);
                        }

                        break;
                    }

                case "LCDG":
                case "LCDT":
                    {
                        await
                            this.dispatcher.RunAsync(
                                CoreDispatcherPriority.Normal, 
                                () => { this.screen.LcdPrint(message as ScreenMessage); });
                        break;
                    }

                case "LOG":
                    {
                        await this.screen.LogPrint(message as ScreenMessage);
                        break;
                    }

                case "SPEECH":
                    {
                        this.Speak(message as SpeechMessage);
                        break;
                    }

                case "RECOGNIZE":
                    {
                        this.Recognize(message as SpeechRecognitionMessage);
                        break;
                    }

                case "SENSORS":
                    {
                        this.ToggleSensors(message as SensorMessage);
                        break;
                    }

                case "WEB":
                    {
                        await this.web.RequestUrl(message as WebMessage);
                        break;
                    }

                case "CAMERA":
                    {
                        var camMsg = message as CameraMessage;
                        if (camMsg.Action != null && camMsg.Message != null && camMsg.Message.Equals("PREVIEW"))
                        {
                            if (camMsg.Action.Equals("ENABLE") && !this.isCameraInitialized)
                            {
                                await this.InitializeCamera();
                                this.camera.isPreviewing = true;
                            }
                            else if (camMsg.Action.Equals("DISABLE"))
                            {
                                this.camera.isPreviewing = false;
                            }
                        }
                        else
                        {
                            await this.TakePicture(message as CameraMessage);
                        }

                        break;
                    }

                case "VIBRATE":
                    {
                        this.Vibrate(message as TimingMessage);
                        break;
                    }

                case "MICROPHONE":
                    {
                        await this.Record(message as TimingMessage);
                        break;
                    }

                case "PLAY":
                    {
                        await this.Play(message as TimingMessage);
                        break;
                    }

                case "DEVICE":
                    {
                        await this.DeviceInfo(message as DeviceMessage);
                        break;
                    }
            }
        }
        private async Task HandleMessageUnprotected(MessageBase message)
        {
            this.Log("R: " + message._Source + "\r\n");

            try
            {
                if (message.Service != "SYSTEM")
                {
                    var dictionary = new Dictionary <string, string> {
                        { "Type", message.Service }
                    };
                    App.Telemetry.TrackEvent("MessageInfo", dictionary);
                }
            }
            catch (Exception)
            {
                // ignore telemetry errors if any
            }

            switch (message.Service)
            {
            case "SYSTEM":
            {
                if (message.Action.Equals("PONG"))
                {
                    var totalRoundTrip = this.recentStringReceivedTick - this.sentPingTick;
                    App.Telemetry.TrackMetric(
                        "VirtualShieldPingPongTimeDifferenceMillisec",
                        totalRoundTrip / TimeSpan.TicksPerMillisecond);
                }
                else if (message.Action.Equals("START"))
                {
                    // reset orientation
                    DisplayInformation.AutoRotationPreferences = DisplayOrientations.None;

                    // turn off all sensors, accept buffer length
                    var switches = new SensorSwitches {
                        A = 0, G = 0, L = 0, M = 0, P = 0, Q = 0
                    };
                    var sensors = new List <SensorSwitches>();
                    sensors.Add(switches);

                    this.ToggleSensors(new SensorMessage {
                            Sensors = sensors, Id = 0
                        });
                }

                break;
            }

            case "SMS":
            {
                var smsService = new Sms();
                var sms        = message as SmsMessage;

                StorageFile attachment = null;
                if (!string.IsNullOrWhiteSpace(sms.Attachment))
                {
                    attachment = await StorageFile.GetFileFromPathAsync(sms.Attachment);
                }

                smsService.Send(sms.To, sms.Message, attachment, null);
                break;
            }

            case "EMAIL":
            {
                var email        = new EmailMessage();
                var emailMessage = message as Core.Models.EmailMessage;
                email.Body    = emailMessage.Message;
                email.Subject = emailMessage.Subject;
                email.To.Add(new EmailRecipient(emailMessage.To));
                if (!string.IsNullOrWhiteSpace(emailMessage.Cc))
                {
                    email.CC.Add(new EmailRecipient(emailMessage.To));
                }

                if (!string.IsNullOrWhiteSpace(emailMessage.Attachment))
                {
                    var storageFile = await StorageFile.GetFileFromPathAsync(emailMessage.Attachment);

                    var stream = RandomAccessStreamReference.CreateFromFile(storageFile);

                    var attachment = new EmailAttachment(storageFile.Name, stream);

                    email.Attachments.Add(attachment);
                }

                await EmailManager.ShowComposeNewEmailAsync(email);

                break;
            }

            case "NOTIFY":
            {
                var notify = message as NotifyMessage;
                if (string.IsNullOrWhiteSpace(notify.Action))
                {
                    return;
                }

                if (notify.Action.ToUpperInvariant().Equals("TOAST"))
                {
                    await this.SendToastNotification(notify);
                }
                else if (notify.Action.ToUpperInvariant().Equals("TILE"))
                {
                    await this.SendTileNotification(notify);
                }

                break;
            }

            case "LCDG":
            case "LCDT":
            {
                await
                this.dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal,
                    () => { this.screen.LcdPrint(message as ScreenMessage); });

                break;
            }

            case "LOG":
            {
                await this.screen.LogPrint(message as ScreenMessage);

                break;
            }

            case "SPEECH":
            {
                this.Speak(message as SpeechMessage);
                break;
            }

            case "RECOGNIZE":
            {
                this.Recognize(message as SpeechRecognitionMessage);
                break;
            }

            case "SENSORS":
            {
                this.ToggleSensors(message as SensorMessage);
                break;
            }

            case "WEB":
            {
                await this.web.RequestUrl(message as WebMessage);

                break;
            }

            case "CAMERA":
            {
                var camMsg = message as CameraMessage;
                if (camMsg.Action != null && camMsg.Message != null && camMsg.Message.Equals("PREVIEW"))
                {
                    if (camMsg.Action.Equals("ENABLE") && !this.isCameraInitialized)
                    {
                        await this.InitializeCamera();

                        this.camera.isPreviewing = true;
                    }
                    else if (camMsg.Action.Equals("DISABLE"))
                    {
                        this.camera.isPreviewing = false;
                    }
                }
                else
                {
                    await this.TakePicture(message as CameraMessage);
                }

                break;
            }

            case "VIBRATE":
            {
                this.Vibrate(message as TimingMessage);
                break;
            }

            case "MICROPHONE":
            {
                await this.Record(message as TimingMessage);

                break;
            }

            case "PLAY":
            {
                await this.Play(message as TimingMessage);

                break;
            }

            case "DEVICE":
            {
                await this.DeviceInfo(message as DeviceMessage);

                break;
            }
            }
        }
        private async void sendEmail(object sender, RoutedEventArgs e)
        {
            var emailMessage = new Windows.ApplicationModel.Email.EmailMessage();

            Contact c = new Contact();
            c.Emails.Add(new ContactEmail() { Address = "*****@*****.**" });

            var email = c.Emails.FirstOrDefault<ContactEmail>();
            if (email != null)
            {
                var emailRecipient = new EmailRecipient(email.Address);
                emailMessage.To.Add(emailRecipient);
            }

            await EmailManager.ShowComposeNewEmailAsync(emailMessage);

        }