示例#1
0
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            /// Windows 7:HKEY_CLASSES_ROOT\mailto\ 可能不存在,IE需要設定Google工具列或是類似的工具,才能開啟mailto:連結
            /// Windows 8:HKEY_CLASSES_ROOT\mailto\ 會存在,但是下面不一定有東西
            /// Windows 10:HKEY_CLASSES_ROOT\mailto\shell\open\command\ 會存在,預設值可能是 C:\windows\system32\rundll32.exe

            bool b = MailToUtility.TestShellValue();

            if (!b)
            {
                b = MailToUtility.TestOpenCommand();
                if (!b)
                {
                    MessageBox.Show("no email client detected");
                }
                else
                {
                    MessageBox.Show("email client detected!");
                }
            }
            else
            {
                MessageBox.Show("email client detected!");
            }
        }
示例#2
0
        private void btnSend_Click(object sender, RoutedEventArgs e)
        {
            /// mailto:[email protected]?
            /// subject=Feedback for webdevelopersnotes.com
            /// &body=The Tips and Tricks section is great
            /// &[email protected]
            /// &bcc = [email protected]
            ///

            string strAddress = tbEmail.Text;
            string strSubject = tbSubject.Text;
            string strBody    = tbContent.Text;
            string strCC      = tbCC.Text;
            string strBCC     = tbBCC.Text;

            char[]        separators = { ';' };
            List <string> vAddress   = new List <string>();

            vAddress.AddRange(strAddress.Split(separators, StringSplitOptions.RemoveEmptyEntries));

            List <string> vCC = new List <string>();

            vCC.AddRange(strCC.Split(separators, StringSplitOptions.RemoveEmptyEntries));

            List <string> vBCC = new List <string>();

            vBCC.AddRange(strBCC.Split(separators, StringSplitOptions.RemoveEmptyEntries));

            string strResult = MailToUtility.SendMailToURI(vAddress, vCC, vBCC, strSubject, strBody);

            if (!string.IsNullOrEmpty(strResult))
            {
                MessageBox.Show(strResult);
            }
        }
示例#3
0
 private void btnTest2_Click(object sender, RoutedEventArgs e)
 {
     if (MailToUtility.IsMailClientInstalledRoot() || MailToUtility.IsMailClientInstalledForUser())
     {
         MessageBox.Show("email client detected!");
     }
     else
     {
         MessageBox.Show("no email client detected");
     }
 }