Shared Mail Inbox Outlook

arjungupta

New Member
Hey,

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

Code:
'Commented out this for use of shared Mailbox
'Dim folder = _nameSpace.GetDefaultFolder(Outlook_Folder_ID)
'Use for functional or shared Mailbox
Dim FMMail = "YOUR FM NAME"
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.

P.S:
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
Marcel

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!
 

Attachments

  • ReadEmailFromSharedMailBoxIssue.PNG
    216.2 KB · Views: 27

Ayyoub

New Member
GetDefaultFolder
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.

https://support.office.com/en-us/ar...nge-mode-7885af08-9a60-4ec3-850a-e221c1ed0c1c
Hi Can you please tell how did you solve the problem?
I want to save attachmenets from shared mailbox?

Thanks in advance
Ayyoub
 

Ayyoub

New Member
@jonnymop5

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.
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))
    recipient.Resolve
    If recipient.Resolved Then recipient.Type = OlMailRecipientType.olTo
    Next
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))
    recipient.Resolve
    If recipient.Resolved Then recipient.Type = OlMailRecipientType.olCC
    Next
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))
    recipient.Resolve
    If recipient.Resolved Then recipient.Type = OlMailRecipientType.olBCC
    Next
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
    mail.Attachments.Add(att)
Next

mail.Save
mail.Send
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,
Ayyoub
 

rahinik

Member
Hi All,

Anyone can help on this to save the attachment from mails present in the subfolder of Inbox. It is pretty urgent.

Thanks
 

drubiano

Member
CAn anyone help on the reading the mail with attachments from shared mail box in blue prism.

Hi Rahinik,

I would recommend that you look at "Blue Prism Digital Exchange" for further VBOs, I have used NEEOPS own VBO that you could download. I have hear that Agilify's VBO is good too
 

ttummala13

New Member
Hi All,

I have a scenario where i need to read a mails from shared email box which contain multiple inboxes(inbox1, inbox2,inbox3,...) how get read mails in this scenario?
Any help would be greatly appreciated. Thanks!!
 

rahinik

Member
Hi Dribiano,

Actually, I took a copy of the inbox - reading mail page in vbo and edited the code and now able to read the mail with attachment from shared mail box(es).
 

diana2020

New Member
Hi,

do you know how to avoid login screen outlook every time I get emails from an shared mailbox account with "Get emails by subject" ?
I am using outlook 2016 on an Terminal server as a RPA resource with an microsoft365 account.
cachedexchangemode is off and I am still getting that sts authentication log in screen.

Thankx.
 

2vinaymurthy

New Member
Hi ,

Tried same thing to get email from Sent Item folder from Shared Mail box.
But getting error "Value does not fall within the expected range." each time.
But same code working fine when tried to get email from Shared mail box Inbox folder.

Thanks in advance. Please provide expertise.
Hi Kalra: Did you able to fix this ? Am trying to read Shared Mail box Sent Item.. Its not working
 
Top