微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Outlook 赎回:带有 ReceivedTime 修改的静默导入

如何解决Outlook 赎回:带有 ReceivedTime 修改的静默导入

请帮助自动化由 2 个订阅组成的流程:

  1. 导入 - 我需要在没有目标和目标文件夹选择对话框的情况下进行静导入。 我需要导入到 Outlook 中的“INBox/Imported”子文件夹,并想了解在此代码中我可以明确提及它的位置。 我需要从文件夹“D:\Emails”中抓取 .EML 文件,而无需用于文件夹选择的冗余对话:
Sub Redemp()
Dim objShell: Set objShell = CreateObject("Shell.Application")
Dim objFolder: Set objFolder = objShell.browseForFolder(0,"Select the folder containing eml-files",0)

Dim Item
If (Not objFolder Is nothing) Then
  Set WShell = CreateObject("WScript.Shell")
  Set objOutlook = CreateObject("outlook.application")
  Set Folder = objOutlook.Session.PickFolder
  If Not Folder Is nothing Then
    For Each Item In objFolder.Items
      If Right(Item.name,4) = ".eml" And Item.IsFolder = False Then
        Set objpost = Folder.Items.Add(6)
        Set objSafePost = CreateObject("Redemption.SafePostItem")
        objSafePost.Item = objpost
        objSafePost.Import Item.Path,1024
        objSafePost.MessageClass = "IPM.Note"
        ' remove IPM.Post icon
    Set utils = CreateObject("Redemption.MAPIUtils")
    PrIconIndex = &H10800003
        utils.HrSetoneProp objSafePost,PrIconIndex,256,True 'Also saves the message
      End If
    Next
  End If
End If

MsgBox "Import completed.",64,"Import EML"

Set objFolder = nothing
Set objShell = nothing
End Sub

此外,最好避免导入的邮件出现在 Outlook 中,就像我已经开始回复一样(不是很方便)。如果我使用上面的代码并选择导入的消息,它看起来不像最初收到的,而是看起来像我回复的文本。

  1. 我需要将下面的代码与上面的导入过程统一起来,以纠正导入消息的 ReceivedTime 属性(或者它可以在导入前修改 EML 文件,操作顺序并不重要)。
Sub Redemp_sentreceived()
    Set rSession = CreateObject("Redemption.RDOSession")
    rSession.MAPIOBJECT = Application.Session.MAPIOBJECT
    Set Msg = rSession.GetRDOObjectFromOutlookObject(Application.ActiveExplorer.CurrentFolder)
    For Each Item In Msg.Items
        Item.ReceivedTime = Item.SentOn
        Item.Save
    Next
End Sub

最终导入的 .EML 文件应位于目标文件夹中,并具有正确的 ReceivedTime。 非常感谢您提前帮助我!

解决方法

在这种情况下真的没有理由使用 Safe*Item 对象 - 使用 RDOSession 对象,就像在第二个示例中一样设置 MAPIOBJECT 属性。

我的头顶:

Set rSession = CreateObject("Redemption.RDOSession")
rSession.MAPIOBJECT = Application.Session.MAPIOBJECT
Set folder = rSession.GetDefaultFolder(plFolderInbox).Folders.Items("Imported")
Set fileFolder = objFSO.GetFolder("D:\Emails")
For Each objFile in fileFolder.Files
    set msg = folder.Items.Add("IPM.Note")
    msg.Sent = true
    msg.Import objFile.Path,1031
    msg.Save
Next
,

问题出在导入中指出的数字(我更改了 1031 -> 1024),现在它就像一个魅力!

Sub MailImport()
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set rSession = CreateObject("Redemption.RDOSession")
rSession.MAPIOBJECT = Application.Session.MAPIOBJECT
Set Folder = rSession.GetDefaultFolder(olFolderInbox)
Set fileFolder = objFSO.GetFolder("D:\Emails")

For Each objFile In fileFolder.Files
    Set msg = Folder.Items.Add("IPM.Note")
    msg.sent = True
    msg.Import objFile.Path,1024
    msg.ReceivedTime = msg.SentOn
    msg.Save
    objFile.Delete
Next

Set objFSO = Nothing
End Sub

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?