简体   繁体   中英

Automatically Send BCCs to Mailbox Sent From

We've got multiple users using an existing mailbox on Outlook. Everyone who sends from the mailbox recieves the "sent items" in their own personal mailbox. I've looked in rules and cannot find anything to have the sent items appear in the group mailbox's sent items instead.

I've got the following code, but cannot work out why it's not running.

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

strBcc = "<mailboxname>"

If Item.SendUsingAccount = "<mailboxname>" Then

Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC

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

End If

Set objRecip = Nothing
End Sub

To have the mail sent from the mailbox account you need to do the following:

With oMailItem
Set .SendUsingAccount = oOutlook.Session.Accounts.Item(iAccount)
...
End With

Where oMailItem and oOutlook refer to your relevant objects and iAccount is the index number of the mailbox you want to use. In my case I have two mailboxes available to send from, my personal one and the group one. My personal account is first (index 1) and the group mailbox is second (index 2).

Mail Items I send using this code always move to the Sent Items folder in the group mailbox rather than my personal one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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