将mailitem移动到已发送的项目

时间:2015-11-22 00:56:26

标签: vba outlook move mailitem

在回复网站上的电子邮件时,我会收到一份回复到我收件箱的回复。我正在创建代码,将更新我的Outlook收件箱并显示原始查询作为回复,然后将我的回复移动到“已发送邮件”文件夹。所有代码都可以工作,除了它不会将mailitem移动到“已发送邮件”文件夹。我不确定“已发送邮件”是限制文件夹,还是我出错了。我的代码如下:

'locate the imap folder rather than the default outlook folder
 Set oFolder= Application.GetNamespace("MAPI").Folders(myIMAPFolder)
 Set oInbox = oFolder.Folders("Inbox")

 'sort the inbox based on the time received to find the most recent mail with  a matching subject and sender
 Set MyItems = oInbox.Items
 MyItems.Sort "ReceivedTime", True
 i = 0
 Do
     i = i + 1
     sSearch = Mid(m.Subject, 5, 100)
     Set oReply = MyItems(i)
 Loop Until oReply.Subject = sSearch And oReply.SenderEmailAddress = m.Recipients(1).Address

 'add the reply icon to the mail in the inbox and mark the original message as being read
 With oReply
     .PropertyAccessor.SetProperty "http://schemas.microsoft.com/mapi/proptag/0x10800003", 261 'standard replied icon
      .UnRead = False
      .Save
  End With

  'move my incoming message to the "Sent Items Folder" & mark as being read
  '**** THIS SECTION OF CODE DOESN'T WORK??? ****
  Set oSent = oFolder.Folders("Sent Items")
  With m
      .Move (oSent)
      .UnRead = False
      .Save
  End With

0 个答案:

没有答案