Question : Sending emails on behalf of a common mail address and have the email saved in "Sent items" in the common mailbox (not my own)

I am using a routine that sends out emails from a MS Access database (see code snippet below). The database is used by 3-4 different people, who all send emails "on behalf of" a common mailbox that they have access to. However, when sending, a copy of the email is saved in "Sent items" in the OWN mailbox, not the common one. This is undesirable, because it prevents the others to see which information has been sent out.

I need to have the outgoing emails stored in the Sent Items folder on the COMMON mailbox (the name of the common mailbox is "ADE NO HR SH" - see code snippet), not each individuals private mailbox.

Can this be done ??  
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
Private Sub Send_Email_Click()
    Dim email As String
    Dim REF As String
    Dim Body As String
    Dim strAttach As String
    Dim objOutlook As Outlook.Application
    Dim objEmail As Outlook.MailItem
    Dim objOutlookAttach As Outlook.Attachment
    Dim strMsg As String
    Dim blAttachment As Boolean
    
    
    On Error GoTo ErrorMessage
    
    email = Me![Borrower_Email_Address]
    REF = Me![Email_Reference]
    Body = Me![Email_Body]
    If Not IsNull(Me.attachment_name) Then
        strAttach = Me![attachment_name]
        blAttachment = True
        Else
        blAttachment = False
    End If
    
    Set objOutlook = CreateObject("Outlook.Application")
    Set objEmail = objOutlook.CreateItem(olMailItem)
    
        With objEmail
            .To = email
            .Subject = REF
            .SentOnBehalfOfName = "ADE NO HR SH"
            ' ******************************
            ' HERE IS WHERE I WANT THE CODE!
            ' ******************************
            .Body = Body
            If blAttachment = True Then
            .Attachments.Add strAttach
            End If
            .Send 'sends the email in Outlook
        End With
    
    Set objEmail = Nothing
    
 ErrorMessage:
    MsgBox Err.Description
End Sub

Answer : Sending emails on behalf of a common mail address and have the email saved in "Sent items" in the common mailbox (not my own)

When it faults, in the immediate window type:

print objOutlook.GetNamespace("MAPI").getdefaultfolder(6).parent.parent.folders("Postboks - ADE NO HR SH")

Depending on if that works:
print objOutlook.GetNamespace("MAPI").getdefaultfolder(6).parent.parent
print objOutlook.GetNamespace("MAPI").getdefaultfolder(6).parent


Chris
Random Solutions  
 
programming4us programming4us