简体   繁体   English

如何在SENT文件夹Outlook 2010 Exchange中删除自动转发的电子邮件

[英]How to delete autoforwarded email in SENT folder Outlook 2010 Exchange

Newbie poster with Outlook VBA. Outlook VBA的新手海报。 Intermediate Excel VBA coder. 中级Excel VBA编码器。

I have a VBA routine that autoforwards all incoming email to a Gmail account. 我有一个VBA例程,可以将所有传入的电子邮件自动转发到Gmail帐户。 It is not all my code, (modified from a blog post) but it works. 它不是我的全部代码(从博客文章中修改),但是可以工作。 I need to keep a copy of all my email received in all my accounts so I can consolidate them into one main one. 我需要保留所有帐户中收到的所有电子邮件的副本,以便将它们合并为一个主要帐户。 In the Outlook 2010 Exchange account, all the forwarded mail gets saved in the SENT folder as a copy. 在Outlook 2010 Exchange帐户中,所有转发的邮件都会作为副本保存在SENT文件夹中。

Is it possible to delete the autoforwarded copy in the SENT folder, without deleting all SENT emails? 是否可以删除SENT文件夹中的自动转发副本,而不删除所有SENT电子邮件? I need to keep the emails I actually respond to. 我需要保留我实际回复的电子邮件。

I would not have a problem using conversation mode in the INBOX, to store the replied to emails. 使用INBOX中的对话模式来存储回复的电子邮件,我不会有问题。 but as it now stands, everything is duplicated due to the bcc copy in the SENT folder when I toggle Conversation mode for the INBOX. 但目前看来,当我切换“收件箱”的“对话”模式时,由于SENT文件夹中的密件抄送副本,所有内容都会重复。

Thanks in advance for any assistance. 在此先感谢您的协助。

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        Dim objRecip As Recipient
        Dim strMsg As String
        Dim res As Integer
        Dim strBcc As String
        On Error Resume Next

        ' #### USER OPTIONS ####
        ' address for Bcc -- must be SMTP address or resolvable
        ' to a name in the address book
        strBcc = "bcc.hwb@gmail.com"

        Set objRecip = Item.Recipients.Add(strBcc)
        objRecip.Type = olBCC
        If Not objRecip.Resolve Then
            strMsg = "Could not resolve the Bcc recipient. " & _
                     "Do you want still to send the message?"
            res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
                    "Could Not Resolve Bcc Recipient")
            If res = vbNo Then
                Cancel = True
            End If
        End If

        Set objRecip = Nothing
    End Sub

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
    Dim varEntryIDs
    Dim objItem
    Dim myItem As MailItem
    Dim i As Integer
    varEntryIDs = Split(EntryIDCollection, ",")
    For i = 0 To UBound(varEntryIDs)
        Set objItem = Application.Session.GetItemFromID(varEntryIDs(i))
        'MsgBox (varEntryIDs(i))

        Set myItem = objItem.Forward
        myItem.Recipients.Add "bcc.hwb@gmail.com"
        myItem.Send

        'myItem.Delete

        Set myItem = Nothing
    Next
End Sub

请参阅MailItem.DeleteAfterSubmit属性(Outlook)

myItem.DeleteAfterSubmit = True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM