Windows Mobile 6.5 Mother of all tutorial : Part 4 ใช้ Contacts

Posted 13/01/2010 14:43 by nantcom

mofat5

imageการติดต่อกับ Contacts ในเครื่อง Windows Mobile โดยการใช้ .NET Compact Framework ต้องทำผ่านระบบ Pocket Outlook ครับ ซึ่งการใช้ Pocket Outlook จาก C# หรือ VB.NET ก็สามารถทำได้โดยการ Add Reference Microsoft.WindowsMobile.PocketOutlook เข้ามา

(ตอน Add Reference ระวังด้วยนะครับ เพราะว่ามันมี 2 ตัว เลือกตัวที่อยู่ใน SDK ของ WM6 นะครับ)

image

ซึ่งคลาสที่เราจะทำงานด้วย ก็คือคลาส Microsoft.WindowsMobile.PocketOutlook.Contact ครับ ซึ่งมีโครงสร้างตามด้านซ้ายมือนี้ Microsoft เขาก็ได้ทำการเก็บค่าต่างๆ ของ Contact ทำเป็น Property ให้เราหมดแล้ว ใช้งานได้ทันที ไม่ต้องคิดมาก

สำหรับการเปิด Contact ขึ้นมาใช้งาน มีโค๊ดดังนี้ครับ

Code Snippet
  1. OutlookSession session = new OutlookSession();
  2. for (int i = 0; i < session.Contacts.Items.Count; i++)
  3. {
  4.     var item = session.Contacts.Items[ i ];
  5.  
  6.     item.Nickname = "HAHA";
  7.  
  8.     item.Update();
  9. }
  10. session.Dispose();

สังเกตว่าเราจะต้องสั่ง Update หลังแก้ไข และต้อง Dispose Session เพื่อ Clear หน่วยความจำที่ใช้ออกด้วยครับ

Published Jan 13 2010, 02:43 PM by nantcom
Filed under:

ร่วมให้กำลังใจนักเขียน

อ่านแล้วชอบใจ อยากให้กำลังใจกับผู้แต่งบทความนี้ ขอเชิญร่วมให้กำลังใจผ่าน Paysbuy/Paypal นะครับ ปลอดภัยเพราะทำงานผ่าน SSL และไม่มีค่าใช้จ่ายเพิ่มเติมครับ เว็บเราให้นักเขียน 100% ครับ

Comment ระบบเก่า

 

welcome said:

&#160; &#160;&#160; Review : Toshiba TG01 สวัสดีปีใหม่ครับ!!!&#160; ปีใหม่นี้ อยากได้หูฟัง Bluetooth

January 14, 2010 12:13 AM
(required)  
(optional)
(required)  
Add

DisQUS Comment (ยังเอ๋อๆ อยู่)

blog comments powered by Disqus