zoukankan      html  css  js  c++  java
  • Mobile 拨打电话 发送短信

    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();
            }
        }
    }

    冯瑞涛
  • 相关阅读:
    spring cloud eureka 配置
    nginx 无法访问root权限的文件内容
    Linux 如何将一个文件夹的所有内容授权给某一个用户
    eclipse 注释字体不一致的问题
    java web 跨域
    tomcat的catalina.out日志文件过大
    linux 安装禅道
    修改rabbitmq Web UI 监控页面的端口
    nginx访问静态文件配置
    centos 安装单机版 redis4.0.10
  • 原文地址:https://www.cnblogs.com/finehappy/p/1521541.html
Copyright © 2011-2022 走看看