I will try to be as clear as possible. There are 5 people on my team. We each have our own personal outlook email accounts. Our team leader is ALSO the owner of an account that we all have access to (call it "SharedAccount#xx.com"). I have macros that I want to put into that shared email account, that will listen to the inbox of that email account and do stuff with the incoming messages. Since I am not the owner of that account, I wrote Macros in my personal email and for the NameSpace business I used the following code (note, again, this is in MY personal email ThisOutlookSession):
Dim objNS As Outlook.NameSpace
Set objNS = olApp.GetNamespace("MAPI")
Dim rec As recipient
Set rec = objNS.CreateRecipient("SharedAccount#xx.com")
rec.Resolve
Set inbox = objNS.GetSharedDefaultFolder(rec, olFolderInbox)
Am I doing this wrong? Do I instead need to put this code into the macros on the "Shared#xx.com" account profile? I know the macros work in regards to the listeners and all that, so the problem has something to do with NameSpaces I feel like. I would really, really appreciate any help I can get. Thank you!
Each user normally accesses their own VbaProject.otm file. See VbaProject.OTM deployment for a description of "a parameter altvba that allows to specify another path to run the OTM file from".
If that is not feasible you could use one of the methods described here. http://www.outlookcode.com/article.aspx?id=28 also referenced in the above.
"The least intrusive technique is to use the File | Export command in the Outlook VBA environment to export modules as .bas, .cls, and .frm files."
"The brute force approach is to copy this file from the machine where the macros were written to other users' machines, replacing any existing VbaProject.otm file." (Not very nice.)
It is easiest for me to send a mail, then paste the text into their editor.
Related
I have a VBA function in our MS Access database that generates Outlook emails and sends them from a shared inbox.
Our company uses Azure Information Protection to protect documents. A label needs to be applied to each email before it is sent (e.g. Public, Business Sensitive, Internal).
Rather than having the user click the label 25 times as it pops up for each email, I am trying to apply it programmatically.
I get error code (-1248837627).
My solution was to grab the labels GUID and then apply it to the email as below. I came across other solutions such as using SendKeys but I prefer it to be a last resort.
With olMail
.To = olSendTo
.Subject = olSubject
.PermissionTemplateGuid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"
.Permission = olPermissionTemplate
'And so on, the email function works great until the above two lines are added
Am I applying the .Permissions or .PermissionTemplateGUID improperly?
I have seen a similar approach to apply labels to Excel documents (grabbing and setting the guid).
The code you posted is used to specify Information Rights Management (IRM) permissions. Azure Information Protection is another story.
You need to add a user property in the following format:
"MSIP_Label_" & guid_internal_use_only & "_Enabled"
But I'd suggest exploring internals of Outlook mail items using MFCMAPI or OutlookSpy to find the exact solution. Try to set it manually then explore internals using these tools.
Is there any way to copy the outlook rule of one account to another account using VBA code. I have researched on the internet I have not found anything related to my question, Pls help me. I will be very thankful to you.
The Outlook object model doesn't provide any property or method for that. However, you can use a low-level functionality to access rules. Use the PropertyAccessor object to get and set item-level properties that are not explicitly exposed in the Outlook object model, or properties for the following non-item objects: AddressEntry, AddressList, Attachment, ExchangeDistributionList, ExchangeUser, Folder, Recipient, and Store.
Rules are kept as hidden items in your Inbox folder (see the associated content which is not visible in the Outlook UI). You may use MFCMAPI or OutlookSpy for exploring the hidden content.
Morning,
I'm trying to identify a way of updating permissions to an Outlook 2010 inbox and all of its subfolders with VBA.
We have an account with a large amount of subfolders that several new users need access to. To assign each of these manually will take hours and I'm looking for an automated process, as this will be a reoccuring task.
Due to administrator restrictions I'm only able to use native VBA.
Is this possible, or am I doomed to hours of mundane repetitive pointing and clicking?
Many thanks
Pete
The Outlook object model (used in VBA) doesn't provide anything for changing folder permissions.
You can use a low-level API - Extended MAPI for accessing permissions. Folder level permissions are stored in folders. You need to get the PR_ACL_TABLE property value using the IMAPIFolder::OpenProperty method. Or you may consider using any third-party wrappers around that API that simplify the dev process. See Changes in Outlook 2010 folder permissions not shown in Active Directory for more information.
Since you are using VBA, Extended MAPI is out of the question (you'd need C++ or Delphi).
If using Redemption is an option (I am its author), you can use its RDOACL object (returned by RDOFolder.ACL property) to manage any Exchange folder permissions:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Folder = Session.GetDefaultFolder(olFolderCalendar)
'make sure we get back an Exchange user
set AddressEntry = Session.AddressBook.GAL.ResolveName("Pete")
set ACE = Folder.ACL.Add(AddressEntry)
ACE.Rights = ROLE_PUBLISH_EDITOR
Is it possible to add / remove members of an Exchange Distribution List using VBA?
I can loop through members using the following code, but I can't seem to add new ones.
Dim olApp As New Outlook.Application 'Start instance of Outlook
Dim olNS As Outlook.NameSpace 'Reference the Outlook namespace and use MAPI
Set olNS = olApp.GetNamespace("MAPI") 'Open the AddressList you want to use
Dim olAddressList As Outlook.AddressList
Set olAddressList = olNS.AddressLists("Global Address List")
olAddressList.AddressEntries.Item(DLList).Members.Item (1).name
The quick answer is no, you cannot add and remove members of an Exchange distribution group using VBA with Exchange Web Services. Distribution groups are managed on the Exchange server and the only way I know of to manage these groups with code is to use cmdlets from the Exchange Management Shell, or API to modify the Active Directory. I recently published an article on MSDN that talks about distribution groups with EWS and there is a section that lists the available cmdlets:
Managing distribution groups by using the Exchange Management Shell
Once you have created a script using these cmdlets you may be able to call the script from your VBA code using the Shell() function. I haven't done this myself but I have seen posts in other forums where people have some success with this. Here's a link to another post to get you started that shows an example of VBA in Excel calling a script:
Can I pass a VBA variable into a called Powershell script?
I hope this information helps. If this does resolve your problem, please mark this post as answered.
Thanks,
--- Bob ---
Bob is incorrect. You can definitely manage DL membership via VBA. I do it all the time. You manage group membership via ADSI and there is a well documented API to do so. Here are some functions I wrote to do it:
http://naterice.com/articles/62
I have a question reffering to Public Folders on Exchange Server.
I have an application (Outlook Com Addin) that need to share settings amonge every Exchange User that have access to Public Folders.
I was thinking about storing settings in MAPI assotiated message (hidden MAPI message). Wirting\Reading data from this message works fine, but I don't have good place to save this item.
I am looking from some sort of global folder or root folder that every user have. I tried All Public Folders folder, but noone can store any item there. I was also thinking about NON_IPM_SUBTREE but I am not sure which folder can be used to write there something.
Maybe someone faced this problem already and have some thoughts about this it?
And to make things clear. I am using Extended MAPI, but if you know any solution that involves Outlook API, I would be interested in that too.
Best regards,
There are no predefined PF folders. Most installations will have "Outlook Security Settings", but that is about it.
There is also a set of hidden folders where Outlook stores f/b info.
Keep in mind that PF is optional as of Exchange 2007. Exchange 2010 does not install PF store by default.