与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);
         }
原文地址:https://www.cnblogs.com/wmz/p/1317072.html