zoukankan      html  css  js  c++  java
  • 与Pocket Outlook相关的一些代码片段(C#)

    NameSpaces
    using Microsoft.WindowsMobile.Forms;
    using Microsoft.WindowsMobile.Telephony;
    using Microsoft.WindowsMobile.PocketOutlook;
    using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
    using Microsoft.WindowsMobile.Status;

    Data Binding
                // I assign the listBox1 to null first to Reset it. This is needed as currently there is no support for BeginUpdate and EndUpdate in the Compact Framework.
                this.listBox1.DataSource = null
                
    this.listBox1.DataSource = this.outlookSession.Contacts.Items;
                
    this.listBox1.DisplayMember = "FileAs";
                
    this.listBox1.ValueMember = "ItemId";

    Contact
            OutlookSession s = new OutlookSession();
            Contact c = new Contact();
            c.FullName = "Warren Tang";
            s.Contacts.Items.Add(c);    //Saved
            c.JobTitle = "Dev";
            c.Update(); //Saved

    SMS
            SmsMessage msg = new SmsMessage();
            msg.To.Add(new Recipient("234324"));
            msg.Body = "Hello, Warren.";
            msg.Send();

    Email

    EmailMessage class: http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.pocketoutlook.emailmessage.aspx


    Phone

                Phone p = new Phone();
                p.Talk("23412341");

    Dialog
            SelectPictureDialog dlg1 = new SelectPictureDialog();
            CameraCaptureDialog dlg2 
    = new CameraCaptureDialog();
            ChooseContactDialog dlg3 
    = new ChooseContactDialog();
            
    if (dlg.ShowDialog() == DialogResult.OK)
            {
                Contact cc 
    = new Contact();
                cc.ItemId 
    = dlg3.SelectedContact.ItemId;
            }


     private void mnuChooseContact_Click(object sender, EventArgs e)
            {
                ChooseContactDialog chooseContactDialog 
    = new ChooseContactDialog();
                SelectPictureDialog selectPictureDialog 
    = new SelectPictureDialog();
                Contact contact 
    = new Contact();

                
    this.mnuChooseContact.Enabled = false;

                
    // Open a PocketOutlook session
                using (OutlookSession session = new OutlookSession())
                {
                    
    // Create a single contact
                    if (session.Contacts.Items.Count <= 0)
                    {
                        contact.FirstName 
    = "Contact";
                        contact.LastName 
    = "With Picture";
                        session.Contacts.Items.Add(contact);
                    }
                    
    else
                    {
                        contact 
    = session.Contacts.Items[0];
                    }

                    
    // Open a ChooseContactDialog and a SelectPictureDialog. If a contact was selected and a picture was chosen,
                    
    // assign the picture to the contact.
                    if ((DialogResult.OK == chooseContactDialog.ShowDialog()) && (DialogResult.OK == selectPictureDialog.ShowDialog()))
                    {
                        contact.SetPicture(selectPictureDialog.FileName);
                        contact.Update();
                        contact.ShowDialog();
                    }
                }

                
    this.mnuChooseContact.Enabled = true;
            }

    Appointment
            Appointment ap = new Appointment();
            ap.Subject 
    = "Not a meeting";
            ap.AllDayEvent 
    = true;
            ap.Start 
    = new DateTime(2005101);
            s.Appointments.Items.Add(ap);
            ap.ShowDialog();    
    //Items can be displayed and edited.

    Add properties to PimItem
           Contact myCustomer = new Contact();
            
    if (!myCustomer.Properties.Contains("Employee ID"))
            {
                myCustomer.Properties.Add(
    "Employee ID"typeof(string));
            }
            myCustomer.Properties[
    "Employee ID"= "X333";

            MessagingApplication ma 
    = new MessagingApplication();

    SMS interception
            MessageInterceptor interceptor = new MessageInterceptor();
            interceptor.InterceptionAction 
    = InterceptionAction.NotifyAndDelete;
           
            interceport.MessageCondition.Property = MessageProperty.Body;
            interceptor.MessageCondition.CompareType =  MessagePropertyCompareType.Equal;
            interceptor.MessageCondition.CompareValue = "asdf";
       
            interceptor.MessageReceived 
    += new MessageInterceptorEventHandler(interceptor_MessageReceived);

    State and Notification Broker
            int degree = SystemState.DisplayRotation;   //Get a state
            string value = ConvertToString(SystemState.GetValue(SystemProperty.DisplayRotation)); //Get value of state

            SystemState s;      
    //Notification
            s.ComparisonType = StatusComparisonType.Equal;
            s.ComparisonValue = 1;
            s = new SystemState(SystemProperty.ActiveApplication);
            s.Changed 
    += new ChangeEventHandler(ChangeOccurred);

    App Launching with S&N Broker (SMS Interceptor is the same)
            SystemState state;

            
    private void Form4_Load(object sender, EventArgs e)
            {
                
    if (!SystemState.IsApplicationLauncherEnabled("MyApp.CradleChanged"))
                {
                    state 
    = new SystemState(SystemProperty.CradlePresent);
                    state.EnableApplicationLauncher(
    "MyApp.CradleChanged");
                }
                
    else
                {
                    state 
    = new SystemState("MyApp.CradleChanged");
                }

                state.Changed 
    += new ChangeEventHandler(stateChanged);
             }
  • 相关阅读:
    C# 图像处理:记录图像处理时间的一个类
    C# 图像处理:将图像(24位真彩)转为 8位灰度图像 采用了内存法,大大提高了效率
    C# 图像处理:复制屏幕到内存中,拷屏操作
    C# 图像处理:Bitmap 与 Image 之间的转换
    C# 图像处理:获取鼠标位置信息(全局)
    C# Liseview的使用方法之一:滚动到选中的行
    C# windows服务:如何获取服务程序所在的文件夹
    C#自制Web 服务器开发:mysql免安装版配置步骤详解分享
    C#自制Web 服务器开发:用C#开发自己的Web服务器
    ROS:ROS操作类MK.cs
  • 原文地址:https://www.cnblogs.com/wmz/p/1317072.html
Copyright © 2011-2022 走看看