最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

excel - SendUsingAccount of Shared Mailbox - Stack Overflow

programmeradmin1浏览0评论

I am trying to find the equivalent of MailItem.SentOnBehalfOf for an AppointmentItem. My extensive research tells me AppointmentItem.SendUsingAccount is the only option.

After re-thinking my e-mails (which recipients must acknowledge receipt of), I thought I could change my automated MailItem to AppointmentItem, as this is a win-win: I receive acknowledgement of the e-mail, and the recipient receives a calendar item (and thus, a handy reminder).

My issue is that, as many users access my Excel Macro-Enabled Workbook, all automated e-mails must be sent on behalf of - their actual names / accounts cannot be displayed as the sender.

For the time-being, I've reverted to only sending MailItem, but would really prefer AppointmentItem. My efforts thus far:

Dim olAppointment As Outlook.AppointmentItem
Dim olNamespace As Outlook.Namespace
Dim olAccount As Outlook.Account
    
Set olAppointment = Outlook.CreateItem(olAppointmentItem)
Set olNamespace = Outlook.GetNamespace("MAPI")
    
For Each olAccount In olNamespace.Accounts
    Debug.Print olAccount.DisplayName
    'Prints the following:
    '[email protected]
    '[email protected]

    'Missing:
    '[email protected]
    '[email protected]
    '[email protected]
Next olAccount

I have two e-mail addresses that are "mine" - my non-anizational personal, and my anizational personal. I am also authorized to send from and access three different Shared Mailboxes. These three do not appear in the immediate window following the above code.

I am assuming these mailboxes are stored elsewhere for me to access.

All three Shared Mailboxes are visible in the left-hand side of my Outlook, where my other mailboxes are located. I can access its folders, calendar, etc., and again, I can use MailItem.SentOnBehalfOf = "Shared Mailbox Name" flawlessly.

I am using Excel 365 to send these automated e-mails. Any help would be appreciated.

To reiterate / TL;DR : I need olAppointmentItem.SendUsingAccount = olAccount ', the account of a Shared Mailbox

EDIT: Using part of an answer that was provided here but is now nowhere to be found, I've created the following code. I feel like I am close to being able to utilize a Store in SendUsingAccount. Anyone else have any pointers?

    Dim olApp As Outlook.Application
    Dim olNamespace As Outlook.Namespace
    Dim olStore As Outlook.Store
    Dim olFolder As Outlook.Folder
    Dim olAccount As Outlook.account
    Dim olAppt As Outlook.AppointmentItem
    
    ' Initialize Outlook application and namespace
    Set olApp = New Outlook.Application
    Set olNamespace = olApp.GetNamespace("MAPI")
    Set olAppt = olApp.CreateItem(olAppointmentItem)    
    Set olStore = olNamespace.Stores("Shared Mailbox 1")

    With olAppt
        .Recipients.Add "[email protected]"
        .Subject = "Testing"
        .Body = "Again, testing"
        .SendUsingAccount = olStore.Account 'Obviously doesn't work, but this is to illustrate my goal
        .Display
    End With
发布评论

评论列表(0)

  1. 暂无评论