随笔 - 5  文章 - 2  trackbacks - 0
<2011年7月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

There can be no Triumph without Loss,No Victory without Suffering,No Freedom without Sacrifice. All you have to decide is what to do with the time that is given to you. Get busy Living, or Get busy Dying?

常用链接

留言簿

随笔分类(4)

随笔档案(5)

文章分类(88)

文章档案(10)

Andriod

Language

OpenCV&OpenSSLink

OpenSource

Others

Python&Ruby

WP7

WTL

搜索

  •  

最新评论

阅读排行榜

评论排行榜

邮件Google一下  应该就是
System.Object

  Microsoft.WindowsMobile.PocketOutlook.Message
     Microsoft.WindowsMobile.PocketOutlook.EmailMessage
     Microsoft.WindowsMobile.PocketOutlook.SmsMessage

C#方式读取似乎很简单
引自:http://kb.cnblogs.com/a/1450367/

WM短信读取(C#)

//采用DataGrid现实

//读取收件箱内信息
private void button1_Click(object sender, EventArgs e)
        {
            DataTable mydt 
= new DataTable();
            mydt.TableName 
= "InBox";
            mydt.Columns.Add(
new DataColumn("SenderName"typeof(string)));
            mydt.Columns.Add(
new DataColumn("SenderAddress"typeof(string)));
            mydt.Columns.Add(
new DataColumn("Subject"typeof(string)));
            mydt.Columns.Add(
new DataColumn("SendTime"typeof(string)));
            mydt.Columns.Add(
new DataColumn("ReceiveTime"typeof(string)));
            mydt.Columns.Add(
new DataColumn("SendTime1"typeof(DateTime)));
            mydt.Columns.Add(
new DataColumn("ReceiveTime1"typeof(DateTime)));
            
if (NetMAPI.MAPIInit())
            {

                NetMAPI mapi 
= new NetMAPI();
                
if (mapi.Login())
                {
                    
if (mapi.OpenMessageStore())
                    {
  
                        
if (mapi.OpenInbox())
                        {

                            
if (mapi.GetContents())
                            {
                                
int count = mapi.GetRowCounts();
                                SmsMessage msg;
                                StringBuilder s 
= new StringBuilder(140);
                                
int i = 0;
                                DataRow dr;
                                
while (mapi.GetNextMessage(out msg, false))
                                {
                                    i
++;
                                    
                                    dr 
= mydt.NewRow();
                                    
                                    msg.GetSenderName(s);
                                    dr[
"SenderName"= s.ToString();
                                    
//MessageBox.Show(s.ToString());
                                    msg.GetSenderEmail(s);
      
                                    dr[
"SenderAddress"= s.ToString();
                                    
//MessageBox.Show(aa);
                                    
//MessageBox.Show(s.ToString());
                                    msg.GetSubject(s);
                                    dr[
"Subject"= s.ToString();
                                    
/**/////MessageBox.Show(s.ToString());
                                    msg.GetSubmitTime(s);
                                    dr[
"SendTime"= s.ToString();
                                    msg.GetReceivedTime(s);
                                    dr[
"ReceiveTime"= s.ToString();
                                    msg.Dispose();
                                    mydt.Rows.Add(dr);
                                    
if (i == count - 1)
                                    {
                                        
break;
                                    }

                                }

                            }
                        }

                    }
                    
                    mapi.Logout();
                }
            }
            
else
            {
                MessageBox.Show(
"faile");
            }
            NetMAPI.Term();
            
this.dataGrid1.DataSource = mydt;
        }

//读取发件箱内短信
private void button2_Click(object sender, EventArgs e)
        {
            DataTable mydt 
= new DataTable();
            mydt.TableName 
= "SendedBox";
            mydt.Columns.Add(
new DataColumn("SenderName"typeof(string)));
            mydt.Columns.Add(
new DataColumn("SenderAddress"typeof(string)));
            mydt.Columns.Add(
new DataColumn("Subject"typeof(string)));
            mydt.Columns.Add(
new DataColumn("SendTime"typeof(string)));
            mydt.Columns.Add(
new DataColumn("ReceiveTime"typeof(string)));
            mydt.Columns.Add(
new DataColumn("SendTime1"typeof(DateTime)));
            mydt.Columns.Add(
new DataColumn("ReceiveTime1"typeof(DateTime)));
            
if (NetMAPI.MAPIInit())
            {

                NetMAPI mapi 
= new NetMAPI();
                
if (mapi.Login())
                {
                    
if (mapi.OpenMessageStore())
                    {

                        
if (mapi.OpenSentItems())
                        {

                            
if (mapi.GetContents())
                            {

                                SmsMessage msg;
                                StringBuilder s 
= new StringBuilder(140);
                                StringBuilder s1 
= new StringBuilder(25);
                                StringBuilder s2 
= new StringBuilder(25);
                                
int i = 0;
                                DataRow dr;
                                
while (mapi.GetNextMessage(out msg, false))
                                {
                                    i
++;

                                    dr 
= mydt.NewRow();
                                    msg.GetRecipients();
                                    SmsMessage.RecipientType tt;
                                    msg.GetNextRecipient(s1, s2, 
out tt);
                                    dr[
"SenderName"= s1.ToString();
      
                                    dr[
"SenderAddress"= s2.ToString();
                                    
//MessageBox.Show(aa);
                                    
//MessageBox.Show(s.ToString());
                                    msg.GetSubject(s);
                                    dr[
"Subject"= s.ToString();
                                    
/**/////MessageBox.Show(s.ToString());
                                    msg.GetSubmitTime(s);
                                    dr[
"SendTime"= s.ToString();
                                    msg.GetReceivedTime(s);
                                    dr[
"ReceiveTime"= s.ToString();
                                    msg.Dispose();
                                    mydt.Rows.Add(dr);
                                    
//if (i > 230)
                                    
//{
                                    
//    break;
                                    
//}

                                }

                            }
                        }

                    }

                    mapi.Logout();
                }
            }
            
else
            {
                MessageBox.Show(
"faile");
            }
            NetMAPI.Term();
            
this.dataGrid1.DataSource = mydt;

        }

//这两段代码读取的是收件箱和发件箱里全部短信,还不是很理想.. 




posted on 2011-07-06 17:14 jemmyLiu 阅读(513) 评论(1)  编辑 收藏 引用

FeedBack:
# re: C#读取WM短信邮件 2011-07-06 19:31 Skill
谁有更好的方式读取邮件
因为我是C++开发的吗
所以对这方面不太了解
类 EmailMessage
  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理