与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;
        }

AddPictureToContact
 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( 2005 10 1 );
        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);
         }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值