随笔 - 705  文章 - 0  评论 - 1103  阅读 - 138万 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Forms;                            //添加引用Microsoft.WindowsMobile.Forms.dll
using Microsoft.WindowsMobile.PocketOutlook;                    //添加引用Microsoft.WindowsMobile.PocketOutlook.dll
using Microsoft.WindowsMobile.Telephony;                        //添加引用Microsoft.WindowsMobile.Telephony.dll

namespace SMSPhone
{
    public partial class MainFrm : Form
    {
        private SmsMessage sms = new SmsMessage();              //Microsoft.WindowsMobile.PocketOutlook名字空间里的短信类,
        private Phone phone = new Phone();                      //Microsoft.WindowsMobile.Telephony名字空间里的电话类
        private ChooseContactDialog dialog = new ChooseContactDialog();         //Microsoft.WindowsMobile.Forms名字空间里联系人类
        public MainFrm()
        {
            InitializeComponent();
        }

        private void AddLinkman_menuItem_Click(object sender, EventArgs e)
        {
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                PhoneNumber_textBox.Text = dialog.SelectedContact.MobileTelephoneNumber;                //将联系的移动号码符给PhoneNumber文件框
            }
        }

        private void SMS_menuItem_Click(object sender, EventArgs e)
        {
            sms.Body = Message_textBox.Text;                        //添加短信正文
            sms.To.Add(new Recipient(PhoneNumber_textBox.Text));                //指定要发送的号码
            sms.RequestDeliveryReport = false;                      //发送成功以后不发送送达通知
            try
            {
                sms.Send();
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "错误", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
            MessageBox.Show("短信发送成功", "成功", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
        }

        private void Phone_menuItem_Click(object sender, EventArgs e)
        {
            try
            {
                phone.Talk(PhoneNumber_textBox.Text);           //拨打指定电话
            }
            catch(Exception err)
            {
                MessageBox.Show(err.Message, "错误", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

posted on   冯瑞涛  阅读(687)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
点击右上角即可分享
微信分享提示