lumisoft StoreMessageFlags删除邮件

.Net技术 码拜 10年前 (2014-11-22) 4105次浏览 0个评论

使用 lumisoft 开发邮箱管理工具时,需要删除邮件,在imap_client_app示例程序中,代码执行正常。但是在应用到项目中时,总是无法实现删除。也无法触发事件。删除方法代码如下:

/// <summary>
/// Deletes specified message.
/// </summary>
/// <param name=”uid”>Message UID.</param>
private void DeleteMessage(long uid)
{
this.Cursor = Cursors.WaitCursor;
try{
/* NOTE: In IMAP message deleting is 2 step operation.
* 1) You need to mark message deleted, by setting “Deleted” flag.
* 2) You need to call Expunge command to force server to dele messages physically.
*/

IMAP_t_SeqSet sequence_set = IMAP_t_SeqSet.Parse(uid.ToString());
m_pImap.StoreMessageFlags(true,sequence_set,IMAP_Flags_SetType.Add,new IMAP_t_MsgFlags(new string[]{IMAP_t_MsgFlags.Deleted}));
m_pImap.Expunge();
}
catch(Exception x){
MessageBox.Show(this,”Error: ” + x.Message,”Error:”,MessageBoxButtons.OK,MessageBoxIcon.Error);
}
this.Cursor = Cursors.Default;
}

删除成功时会触发如下事件

/// <summary>
/// This method is called when IMAP server has expunged specified message.
/// </summary>
/// <param name=”sender”>Sender.</param>
/// <param name=”e”>Event data.</param>
private void m_pImap_MessageExpunged(object sender,EventArgs<IMAP_r_u_Expunge> e)
{
if(m_pTabPageMail_Messages.Items.Count >= e.Value.SeqNo){
m_pTabPageMail_Messages.Items.RemoveAt(e.Value.SeqNo – 1);
}
}

经过多次Google未果,最后发现了和示例的区别,本人项目在删除邮件前并未选中邮件所在的相应文件夹,即m_pImap.SelectFolder();


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明lumisoft StoreMessageFlags删除邮件
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!