Shared Mail Inbox Outlook


i was facing the same problem when trying to read mails from a shared mailbox.
If you need this function you have to change the Internal_Get Items of the MS Outlook Email VBO or better create a new VBO e.g. MS Outlook SharedFolder VBO.

Comment out the function GetDefaultFolder in the Code stage and paste in the following code

'Commented out this for use of shared Mailbox
'Dim folder = _nameSpace.GetDefaultFolder(Outlook_Folder_ID)
'Use for functional or shared Mailbox
Dim vRecipient = _nameSpace.CreateRecipient(FMMail)
Dim folder = _nameSpace.GetSharedDefaultFolder(vRecipient, Outlook_Folder_ID)
You could add a new Parameter for your FMMail to get the mails of share dynamically.
Unfortunatly the "Internal_Get Items" Method is only used for some actions in the MS Outlook Email VBO so you can't use all the actions of it e.g.
"Send Email", "Delete Email" etc.. If you need all actions create a new VBO e.g. MS Outlook SharedFolder VBO and replace every GetDefaultFolder functions in the code stages.

Blue Prisms Outlook VBO does not sync mails automatically.
If you call the action Get Received Items you may not get new incoming messages. In this case you could let outlook run in background, call the method multiple times or even better sync the folders by using SyncObjects or SendAndReceive function.

Best Regards
5/6/2020 - I tried the same code but it does not work for me. I have the shared mailbox added in the Outlook client (I just have 1 default profile with my email address as the default mailbox and then a shared mailbox is also added). I am trying to read the emails of a sub-folder inside the inbox folder of this shared mailbox. We are on version 6.7. Its not working. What could be my mistake here? Thanks in advance for the help!


Yesterday, I tried reading mail from an Inbox subfolder of a shared mailbox after implementing the code above. I couldn't get it to work. I was also getting an error stating: "Could not execute code stage because exception thrown by code stage: The attempted operation failed. An object could not be found."

Today, I'm not trying the code again cause I know it didn't work the previous day. So I have a look at this post again, wondering if I missed something. I then notice @drubiano has brought a slight modification to the code. So I figure it wouldn't hurt to try this out, even though I had a feeling it did pretty much the exact same thing. It worked! I was able to read from an Inbox subfolder of a shared mailbox.

I'm really happy, thinking @drubiano's code is what made it work. So I then proceed with making modifications to other code has I now need to move mail from a shared mailbox Inbox subfolder to another subfolder in that same shared mailbox. To test it out, I create a new subfolder and proceed with it. I run the code again to read the mail, and it no longer works, while it worked a minute ago!

I notice @drubiano above mentioned the code wasn't working for him and then suddenly, it started working and he didn't know what he changed. That lead me to wonder... Is it possible that the Microsoft Exchange Server takes time to react to subfolder structure modifications brought to a shared mailbox and that these modifications have an impact, preventing the code from being able to find these subfolders until the server refreshes?

You bet it does! If you have Cached Exchange Mode turned on in your Outlook settings, you'll have issues with your code every time your folder structure changes, until your cache is refreshed. Turn off the Cached Exchange Mode and you'll be fine.

This is where you'll find out how to modify this setting. Of course, you need to turn it OFF, not ON like this link is telling you.
Hi Can you please tell how did you solve the problem?
I want to save attachmenets from shared mailbox?

Thanks in advance

They say an image is worth a thousand words. So here are the screenshots and the full code that enables to send an email from a shared mailbox. I've also added a little bonus for adding a priority level to the email, which isn't part of the original Blue Prism code.
Dim app = CreateObject("Outlook.Application")
Dim mail = app.CreateItem(0)
Dim addressCount As Integer

If [To] <> "" Then
    Dim toAddresses = Split([To], ";")
    For addressCount = LBound(toAddresses) To UBound(toAddresses)
    Dim recipient = mail.Recipients.Add(toAddresses(addressCount))
    If recipient.Resolved Then recipient.Type = OlMailRecipientType.olTo
End if

If CC <> "" Then
    Dim ccAddresses = Split([CC], ";")
    addressCount = 0
    For addressCount = LBound(ccAddresses) To UBound(ccAddresses)
    Dim recipient = mail.Recipients.Add(ccAddresses(addressCount))
    If recipient.Resolved Then recipient.Type = OlMailRecipientType.olCC
End If

If BCC <> "" Then
    Dim bccAddresses = Split([BCC], ";")
    addressCount = 0
    For addressCount = LBound(bccAddresses) To UBound(bccAddresses)
    Dim recipient = mail.Recipients.Add(bccAddresses(addressCount))
    If recipient.Resolved Then recipient.Type = OlMailRecipientType.olBCC
End If

mail.Subject = Subject
mail.HTMLBody = Message

If On_Behalf_Of <> Nothing
    mail.SentOnBehalfOfName = On_Behalf_Of
End if

Select Case Priority_Level
    Case 0
        mail.Importance = 0
    Case 2
        mail.Importance = 2
    Case Else
        mail.Importance = 1
End Select

For Each att As String In Attachments.Split(";"c)
    If att = "" Then Continue For

Hi GatesV,

Thanks for your screenshots it is really helpful.
I'm trying to save attachments from shared mailbox but I don't know how to do it.
If you could share some screenshots and code as you did for Send Email, it will be Nice.

Thanks in advance,