Outlook automation / Object Model query (Python) - unique ID for each email? - python

I've been using the MSDN to build a simple app that automates some Outlook 2010 basics.
It's going well, but I'm just stuck at something simple I think.
My question is this:
I've been able to get objects based on email folders, and even emails, and iterate through them, outputting email subjects as strings, or folder names as strings.
I've been able to get the info into listboxes, but I'm wondering, let's say I want to do something with a specific email I have selected in a listbox, does anybody know if the mailitem object has a property like a unique ID that I could have hidden somewhere or in a SQLite DB that I could use as a reference to do something with said email instead of having to search through the folder again by subject or name ?
The same question kinda applies to what I'm doing to find a specific folder, looping through the inbox folder and if I find the folder by name, then output that folder object. Surely there's a more efficient way to search by name in one step, without looping through folders to find subfolders etc ?
This isn't necessarily a python question, more about how the objects work.
Any help is much appreciated
MSDN Links:
Outlook Object Model Reference
http://msdn.microsoft.com/en-us/library/office/ff870566%28v=office.14%29.aspx
Folders Object
http://msdn.microsoft.com/en-us/library/office/ff870798%28v=office.14%29.aspx
Items Object
http://msdn.microsoft.com/en-us/library/office/ff870897%28v=office.14%29.aspx
MailItem Object
http://msdn.microsoft.com/en-us/library/office/ff870912%28v=office.14%29.aspx

You are probably looking for EntryID.
But please be aware that this ID is only unique/constant per .pst file.

Related

Rename system folder using sql query in python

I have made a power automate flow that runs when someone submit a Microsoft form, the result will create a folder of the name of the person who filled that form (Name field is mandatory in the form) and store the files into that folder he has attached at the time of filling the form. Names also gets updated in the database under xyz table. It is sure that if 10 people fill the form in a day then in database also there will be 10 rows added under Name column.
In xyz table there is one more column named surname. It also gets updated along with name column.
example below:
Name Surname
David Warner
Shane Watson
What I want is to make a python script that check names from the database daily and change folder names to surname. Basically, the script will check if name = David then changes the folder name to Warner and if name = Shane then changes it to Watson and so on... I have no idea how to rename like this.
Actually it makes your work hard when some names may be duplicated and folder names can't be. I recommend you to use sth like unique primary key as auto increment and make folder for every id of users. In such case you don't need to change anything. It is a little bit hard to find out files but it is easy to implement.
Another way to implement sth like this is to structure folder based on Year/Month/Day of creation. This is organized and you can store the file path as another field in DB and easily access them.

Python: Lookup List of Emails Across Various URLs, Return Specific Information

Here's my dilemma.
I have a couple of excel workbooks, let's call them workbook-A and workbook-B.
Workbook-A holds a unique identifier, which happens to be a list of email addresses.
On workbook-B, I have a list of URLs, each URL opens a unique online excel workbook with information that includes emails as well.
Here is what I'm asking for help with.
What would be the best approach to have python take each email address on workbook-A, and look it up against the list of URLs in workbook-B, and then return which URL it found it on in workbook-A (on a blank column)?
Here is a diagram to further explain what I'm asking.
Logic Diagram

Task Automation Help: (no similar entries)

Problem: I’m a nurse, and part of my job is to pull up a list of “unsigned services”. Then of course, take these charts, and send them to the right person.
The person before me did not do this, leaving me THOUSANDS of charts to pull up by patient name and DOB, select the right document, and send to the right person.
I have figured out how to use selenium with python to automate logging in, using input to send keys to search the correct patient, and even to pull up the correct document that needs signed.
How do I have the program do this, for every chart? How do I have python work down the list of names and DOB’s without my having to manually put them in?
Anything I look for on my own is just examples of applying a basic function to a list of numbers and that isn’t my goal.
Thanks for your help!

Using Discord user ID to store data in .JSON file

I feel like the title of this problem just made this whole thing even more confusing. But here is the long of it:
I have a bot that uses .JSON files to store information a user puts into it upon creation. However, to ensure that they are creating one, and only one, file, I have tied it to their unique ID. This ensures that even if a user changes nicknames, he can only create one file for himself. Of course, the .JSON file in the background, will be named '123456789.txt'.
This has been done successfully, but I want to add in bot commands that will allow OTHER users to obtain information stored in that user's file. So, for example: If Joe wants to see what Ned's favorite color is, he could use a simple command like:
!favcolor Ned
And the bot will fine Ned's .JSON file (123456789.txt), look for what value is stored under the key "color", and print out the results.
The problem isn't that I can't find people's user ID (ctx.message.author.id). The problem is that I don't know how to let someone else do such, as, as far as I can find out, there is no way to ensure that when someone precedes '!favcolor' with 'Ned', the bot will find 123456789.txt.
The only solution I can think of at the moment is to maintain a .JSON file at the moment of creation of a file that grabs the user's unique ID, and then pairs it with the name of the user. Something like:
{
"Ned": "123456789"
"Joe": "234567891"
"Sam": "345678912"
}
And so on. Then it just looks at that JSON, and grabs the correct ID. Is this a good approach? Or am I missing something much easier that is already built into discord.py?
Discord users are only uniquely identifiable by ID or username#discriminator.
You can easily get the ID from a User object, given that you're able to identify it from the user input in question.
A .JSON file with a .txt extension is contradictory, and you should be storing JSON data in JSON files rather than text files.
Also, I'd recommend using a database rather than JSON files, as there are lot of advantages to doing so and a lot of disadvantages to continuing to use JSON files.

How do I generate alfresco sites where different users can see different content?

I'd like to build a site which contains a few folders for different teams. However, there is one team that is common to one folder on all sites. I do not want that team to be allowed to see the content of the other folders. I tried creating a folder in a site and giving permission to a user via CMIS (in python), however that folder doesn't seem to be accessible from their share UI.
I'm not even sure this is the best way to do this. The organisation of the information requires that the areas are in the same place (i.e. the same site) however if you have access to the site you seem to have access to all the folders (I can't figure out a way of removing access to a folder on a site for a single user)
Also the requirement here is that it needs to be done programmatically; I'm not bothered particularly about using CMIS and if I have to rewrite the file/folder code, but in my head the best thing to do would be to add a widget on the share UI that access all the folders that a user has access to in the absence of being able to deny access to a folder.
As Gagravarr says you are going to have to break inheritance on the documentLibrary folder to get it to work like you want. Breaking inheritance is not supported by CMIS so you'll have to write your own web script to do that.
I would manually set the permissions until it works like you want it to, then once you get that working, write a web script that puts it into effect for all of your sites.
A share site comes with a security model where every person goes in at least one of four groups: Manager, Collaborator, Contributor and Consumer - either directly or indirectly via another group. Access is generally managed by access control lists. You might want to look at Alfresco: Folder permission by role to get an idea how that works. The site security model does not work for you if you find the need for more than those four groups to map access control. It can still be done, but I would strongly discourage you implementing that because it can get very hard to understand quickly.

Categories