您的位置:首页 > 大数据 > 人工智能

拨打电话 挂断电话 发送短信 发送Email Email发送附件 设置约会

2010-08-21 08:43 465 查看
//////////////////////////////////////////////////////////////////////////
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.Telephony; //拨打电话
using Microsoft.WindowsMobile.PocketOutlook; //发送短信
using Microsoft.WindowsMobile.Forms; //发送邮件

using System.Runtime.InteropServices; //DLL 调用

//using System.IntPtr.IntPtr;
//using System.Collections.Generic;
//using System.Text;

//using ManagedService;
using Microsoft.WindowsMobile.Status;
using System.IO;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
//using Microsoft.WindowsMobile.PocketOutlook;

namespace _8888888
{

public partial class Form1 : Form
{

[DllImport("user32.dll", EntryPoint = "keybd_event")]
public static extern void keybd_event(
byte bVk,
byte bScan,
int dwFlags, //这里是整数类型 0 为按下,2为释放
int dwExtraInfo //这里是整数类型 一般情况下设成为 0

);

public delegate void RILRESULTCALLBACK(uint dwCode, IntPtr hrCmdID, IntPtr lpData, uint cbData, uint dwParam);
public delegate void RILNOTIFYCALLBACK(uint dwCode, IntPtr lpData, uint cbData, uint dwParam);

[DllImport("ril.dll", EntryPoint = "RIL_Initialize")]
private static extern IntPtr RIL_Initialize(int dwIndex, RILRESULTCALLBACK pfnResult, RILNOTIFYCALLBACK pfnNotify, int dwNotificationClasses, int dwParam, out IntPtr lphRil);
[DllImport("ril.dll", EntryPoint = "RIL_Hangup")]
private static extern IntPtr RIL_Hangup(IntPtr hRil);

//RILRESULTCALLBACK result = new RILRESULTCALLBACK(f_result);
// RILNOTIFYCALLBACK notify = new RILNOTIFYCALLBACK(f_notify);
// IntPtr hRil = RIL_Initialize(1,result, notify, 0x00ff0000, g_RILData, out g_hRil); //hRil回傳為0,代表執行成功

//IntPtr hRil = RIL_Initialize(1, new RILRESULTCALLBACK(rilResultCallBack), null, 0, 0, out g_hRil);
//private void rilResultCallback(uint dwCode, IntPtr hrCmdID, IntPtr lpData, uint cbData, uint dwParam)
// public static void rilResultCallBack(uint dwCode,
// IntPtr hrCmdID,
// IntPtr lpData,
// uint cdData,
// uint dwParam)
//{
//MessageBox.Show("something happened!");
//}
//IntPtr HRilHdl;
//IntPtr hRil = IntPtr.Zero;
//IntPtr hRes = IntPtr.Zero;
//IntPtr hRil = RIL_Initialize(1, new RILRESULTCALLBACK(rilResultCallback), null, 0, (int)0x00ff0000, out hRes);
//hRil = RIL_Initialize(1,new RILRESULTCALLBACK(rilResultCallBack),null,0,0,out hRil);

Microsoft.WindowsMobile.Telephony.Phone currentPhone = new Microsoft.WindowsMobile.Telephony.Phone();

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Phone phone = new Phone();
phone.Talk("13334567890");//数字字符串后面可以还,跟一个布尔值,表示是否需要做 一个对号码的确认。这里是默认为False
}

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

private void button3_Click(object sender, EventArgs e)
{
//currentPhone.Talk("117", false); //撥打電話117,可接通
// IntPtr mytest = RIL_Hangup(hRil); //mytest回傳為負數,代表執行失敗 挂断电话

//keybd_event(73, 0, 0, 0);
//System.Threading.Thread.Sleep(100); //Sleep for some time
// keybd_event(0x73, 0, KEYEVENTF_KEYUP, 0);

}

private void button4_Click(object sender, EventArgs e)
{
SmsMessage smsmesage = new SmsMessage();
smsmesage.Body = "welcome to CCMTC!"; //发送内容
smsmesage.To.Add(new Recipient("huang", "13334567890")); //发送人 手机号
smsmesage.RequestDeliveryReport = true; //用来设置是否需要发送回应
smsmesage.Send();
}

private void button5_Click(object sender, EventArgs e)
{
EmailMessage emessage = new EmailMessage();
emessage.Subject = "Title of the mail";
emessage.BodyText = "here is the content";
emessage.To.Add(new Recipient("huang", "316118740@qq.com"));
emessage.Send("ActiveSync");
}

private void button6_Click(object sender, EventArgs e)
{
// using Microsoft.WindowsMobile.PocketOutlook;
// using Microsoft.WindowsMobile.Forms;
// ...
ChooseContactDialog contactDialog = new ChooseContactDialog();//这个对画框的用 法见下文
contactDialog.Title = "Select user to send message";
if (contactDialog.ShowDialog() == DialogResult.OK)
{
EmailMessage message = new EmailMessage();
message.To.Add(new Recipient(contactDialog.SelectedContact.Email1Address));
message.Subject = "picture"; message.BodyText = "This is My picture";
message.Attachments.Add(new Attachment(@"/My Do***ents/Myphoto.jpg"));
//绑定 附件
// using (OutlookSession OutlookSessionsession = new OutlookSession())
// {
// session.EmailAccounts[0].Send(message);//指定发送的帐户
// }
}

}

private void button7_Click(object sender, EventArgs e)
{
OutlookSession os = new OutlookSession();
Appointment ap = new Appointment();
ap.Subject = "找小王"; //标题
ap.Body = "要钱啊 !!!!!!!"; //内容
ap.Start = DateTime.Now;
//ap.Duration = new TimeSpan(02, 00, 00);//约会的持续时间 2小时
ap.End = new DateTime(2010,6,30,20,30,0);
//ye可以直接设置约会的结束时间
os.Appointments.Items.Add(ap);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: