GithubHelp home page GithubHelp logo

jensastrup / pyoutlook Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 4.0 2.82 MB

A Python module for connecting to the Outlook REST API, without the hassle of dealing with the JSON formatting for requests/responses and the REST endpoints and their varying requirements. Maintained on GitLab now:

Home Page: https://gitlab.com/jensastrup/pyOutlook

License: MIT License

Python 100.00%

pyoutlook's People

Contributors

jensastrup avatar zazyzaya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyoutlook's Issues

Error for message missing from email address

Hi, I'm getting a KeyError when reading emails using get_inbox().

Traceback (most recent call last):
  File "read_mail2.py", line 30, in <module>
    inbox = account_one.get_inbox()
  File "C:\Users\Alan\Projects\read_email\venv\lib\site-packages\pyOutlook\core\main.py", line 90, in get_inbox
    return retrieve.get_inbox(self)
  File "C:\Users\Alan\Projects\read_email\venv\lib\site-packages\pyOutlook\internal\retrieve.py", line 66, in get_inbox
    return clean_return_multiple(r.json())
  File "C:\Users\Alan\Projects\read_email\venv\lib\site-packages\pyOutlook\internal\retrieve.py", line 22, in clean_return_multiple
    sender_email = key['Sender']['EmailAddress']['Address']
KeyError: 'Address'

Investigation showed that I had an email from Microsoft Outlook Calendar with the subject Daily schedule on Sunday, 1 January 2017. This email did not include a from email address; just a name. The JSON is below.

    'From': {
        'EmailAddress': {
            'Name': 'Microsoft Outlook Calendar'
        }
    },

To fix the logic below could be added to clean_return_multiple().

            if 'Address' in key['Sender']['EmailAddress']:
                sender_email = key['Sender']['EmailAddress']['Address']
            else:
                sender_email = "None"

Issues with python syntax in main.py on line 31, 79, 88, 157

It seems that there is something wrong with the syntax in the following lines.

031: def get_message(self, message_id) -> Message:
079: def new_email(self, body='', subject='', to: List[Contact] = list):
088: def send_email(self, body=None, subject=None, to: List[Contact] = list, cc=None, bcc=None, send_as=None, attachments=None):
157: def _get_messages_from_folder_name(self, folder_name: str):

How to get to get access token for demon app.

Hi I want to create a demon app which has should not access the browser and till now all the methods I have explored are using web browser for getting access code. Any hint or guidance is appreciated.

are there plans for accessing Outlook calendar?

Hi,

additional to handling Outlook's emails via python, it would be handy to be able to manage TASKS and CALENDAR entries using a Python interface.

Are there plans for including these kind of features into pyOutlook's code base?

Thanks.

Encryption support

It would be very helpful if this included support for sending encrypted emails.

Move all Exception classes

Starting to get messy and duplication is beginning to occur, should all be moved to internal_methods.py

Where to get a "static" api key?

Hello, so currently I'm getting my api key from here, but it seems that it resets every like 40 minutes. (Yes, I've linked my Outlook account)
Where do you guys get your key?

Emails not being deleted

Hey, so I've got this code:


            elif "[Auth2]" in email.subject:
                if email.subject.split()[2] == str(pswd):
                    username = email.subject.split()[1]
                    email.move_to_deleted()
                    authenticateUser(username)

But my emails aren't getting deleted, they remain in my inbox and the command runs without an error.

Class not utilized

message_actions.py has class SendError(Exception) which doesn't appear to be utilized, should be removed.

Trouble sending test email

Hey Jens,

First of all thanks for making this.
So I'm trying to send something really simple (I have pyOutlook 4.2.1):

outlook = OutlookAccount(token)

outlook.send_email(to=['[email protected]'], subject=['Test'], body=['Test email, please ignore.'])

My token is a string as per the docs. I've printed it and it looks good.

But when I try to run it I get this exception:
`

File "c:/users/s.thompson/documents/python scripts/breachedissues.py", line 72, in ExampleOAuth2Client
outlook.send_email(to=[''], subject=['Test'], body=['Test email, please ignore.'])

File "", line 1, in
debugfile('C:/Users/s.thompson/Documents/Python Scripts/breachedissues.py', wdir='C:/Users/s.thompson/Documents/Python Scripts')

File "C:\Users\s.thompson\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 888, in debugfile
debugger.run("runfile(%r, args=%r, wdir=%r)" % (filename, args, wdir))

File "C:\Users\s.thompson\AppData\Local\Continuum\Anaconda3\lib\bdb.py", line 431, in run
exec(cmd, globals, locals)

File "", line 1, in

File "C:\Users\s.thompson\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)

File "C:\Users\s.thompson\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "c:/users/s.thompson/documents/python scripts/breachedissues.py", line 2, in
from jira import JIRA

File "C:\Users\s.thompson\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyOutlook\core\main.py", line 214, in send_email

File "C:\Users\s.thompson\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyOutlook\core\message.py", line 308, in send
self._make_api_call('post', endpoint=endpoint, data=json.dumps(payload))

File "C:\Users\s.thompson\AppData\Local\Continuum\Anaconda3\lib\site-packages\pyOutlook\core\message.py", line 278, in _make_api_call
headers = {"Authorization": "Bearer " + self.account.access_token, "Content-Type": "application/json"}
AttributeError: 'str' object has no attribute 'access_token'`

Why is this? Looking at init in message.py the second param is account, but main.py seems to pass in self.access_token whenever it creates a message?
Am I missing something obvious?

Thanks a lot,

Shamara

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.