复制到Outlook公用文件夹时丢失电子邮件属性

时间:2012-08-14 15:22:54

标签: vba outlook

我的VBA应用程序将选定的,本地存储的电子邮件移动/复制到我有完全访问权限的指定公用文件夹。

问题是在移动/复制电子邮件后,To和From属性会搞乱。那就是:

原文来自:GuyA

原文To:Me

搬家后:我

移动后:公用文件夹的名称

我尝试了以下操作,但它似乎对公用文件夹中的电子邮件没有任何影响

For Each email In a1Bucket.items
    sender = email.SentOnBehalfOfName
    receiver = email.ReceivedOnBehalfOfName
    email.Move largeBucket
    email.SentOnBehalfOfName = sender
    email.To = receiver
Next

我错过了什么?

2 个答案:

答案 0 :(得分:2)

尝试此操作(测试本地文件夹

For Each Email In a1Bucket.items
    sender = Email.SentOnBehalfOfName
    receiver = Email.ReceivedOnBehalfOfName
    Set currentMailItem = Email.Move (largeBucket)
    currentMailItem.SentOnBehalfOfName = sender
    currentMailItem.To = receiver
    currentMailItem.Save
Next

答案 1 :(得分:0)

尝试:

Dim newEMail As Outlook.MailItem    
For Each email In a1Bucket.items
    sender = email.SentOnBehalfOfName
    receiver = email.ReceivedOnBehalfOfName
    Set newEMail = objmail.Move(largeBucket)
    'email.Move largeBucket
    newEMail.SentOnBehalfOfName = sender
    newEMail.To = receiver
Next

您可能还需要在此之后保存。使用上面的代码保留对象的引用 - 移动后。

以下内容:

email.SentOnBehalfOfName = sender
email.To = receiver

仅修改原始电子邮件(后移动的电子邮件)。它与新的电子邮件/邮件对象无关。