How to SEARCH and ORGANIZE your mailbox with Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 พ.ย. 2024

ความคิดเห็น • 70

  • @lucas.oliveira.pessoal
    @lucas.oliveira.pessoal 3 ปีที่แล้ว +1

    thanks for this video. It helped me a lot in my work. Just one question: What if I want to capture all the unread messages? How do I code such thing?

  • @keelanurnishanth5801
    @keelanurnishanth5801 3 ปีที่แล้ว

    Awesome Vid thanks to you i got an idea to automate a redundant task i do every day at work. Would be good if i could get some guidance here I only started learning python recently. Is there a way to get emails during a specific time. My code involves with doing automating something i am able to complete the automation part but am stuck with the part to get emails during a specific time. I used GetLast() to get the last email.

  • @SasiKumar-te1ir
    @SasiKumar-te1ir 4 ปีที่แล้ว +3

    Hi Bro, Thank you for making this video. It is really helpful for everyone. Could you please make an another video, how to copy excel table with specific range and paste in outlook body of email using python.

    • @izzyanalytics4145
      @izzyanalytics4145  4 ปีที่แล้ว +3

      yes. There are a few ways to do this. I'll put this on the schedule.

  • @AmitKumar-zk3xr
    @AmitKumar-zk3xr 2 ปีที่แล้ว

    @Izzy Analytics Thanks so much for the video but i am getting error while searching a keyword in body part. I have around 500 emails in Inbox.
    mes1 = [message for message in inbox.Items if 'Pay' in message.Body]
    Please help me and let me know if i am making any mistakes

  • @xinll
    @xinll 4 ปีที่แล้ว +1

    Hi Izzy, thx for such a great video series. I'm trying to move my mails into another folder. My "for" loop works but get somehow interupted. 4 out of 7 emails moves in the first run. I just start the same loop again, this time 2 of 3. And one more time to start the loop and finaly all are in the right folder. I've tried it with a while loop - same result. Do you have any idea? Maybe my Outlook 365 interupt the access of a 3rd software?

    • @izzyanalytics4145
      @izzyanalytics4145  4 ปีที่แล้ว +1

      You may need to create a reference to the emails first by adding them to a list. Then, you can iterate over the list to perform your actions. I've found that iterating over the COM objects directly causes the iteration to get out of sync.

    • @xinll
      @xinll 4 ปีที่แล้ว

      @@izzyanalytics4145 Thx Izzy! It works right now.

    • @xinll
      @xinll 4 ปีที่แล้ว

      @@izzyanalytics4145 one more question. I want to handle attachments and save them on my computer. Do i really need to use getFirst() and getNext() to handle? I already have all mails in a list to work with. But when Im using .Attachments, i get an error.

    • @izzyanalytics4145
      @izzyanalytics4145  4 ปีที่แล้ว +2

      This is a script that I used to demonstrate how to download attachments. Let me know if this works for your case.: github.com/israel-dryer/Outlook-Python-Tutorial/wiki/Download-email-attachments

    • @xinll
      @xinll 4 ปีที่แล้ว +1

      @@izzyanalytics4145 Im going to try this one tomorrow. Looks less complex as what i have done :)) thx again!

  • @critical-chris
    @critical-chris ปีที่แล้ว

    How much would it take to implement a bayesian filter that filters your incoming emails like spam filters, but distinguishing not just ham and spam but multiple types of ham?

  • @kwongxindi4592
    @kwongxindi4592 3 ปีที่แล้ว +1

    Hi is python able to find an email using the email subject in all of the folders (including the sub folders) e.g. I want to find an email with subject 'happy' but it is in one of the sub folders. Can I find the email without knowing which sub folder it is in?

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว

      yes, you can do this with a recursive search: github.com/israel-dryer/Outlook-Python-Tutorial/wiki/Search-and-Organize-Mail#recursive-searches

  • @basavrajr8577
    @basavrajr8577 2 ปีที่แล้ว

    Hi Izzy thanks for cool secession....
    >> can we do-- the multiple mail(eg- 3-5) can we consolidate in one mail(With attachment) and send it to particular mail.. via Outlook.

  • @williambeasley838
    @williambeasley838 3 ปีที่แล้ว

    Izzy, great short how to video!! I would love to see how to access archive .pst files. I opened a .PST from my portable drive into my outlook, but it did not see the Archive folder. Also would love to see how to just save any attachments into a specified folder.

  • @kolidancer1013
    @kolidancer1013 3 ปีที่แล้ว +1

    Great Video, very helpful! This is almost what I want to do. I am wondering if you could write a few words or create a new video on the following. I get a lot of emails and I want to reply to specific emails that contain specific words such as java with a specific message and words such as python with specific message on a continuous basis. Any ideas on this? Thank you!

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว

      gist.github.com/israel-dryer/79dfa1b62e3015d0223e4fc072b7b410

  • @SAShetty57
    @SAShetty57 3 ปีที่แล้ว

    Hi Izzy, Thank you so much for detailed explanation, I have one important doubt, it is " When I'm in cc of a received email in Outlook, how can I fetch the Recipient's email adress with reference to specific Sender's email id", Thanks in advance for the Help.

  • @carzetonao
    @carzetonao 2 ปีที่แล้ว

    Enjoy the video

  • @benward8756
    @benward8756 3 ปีที่แล้ว

    Saved my life, thank you!!

  • @mariabelenbernatene2484
    @mariabelenbernatene2484 2 ปีที่แล้ว

    hi! Thank you for this video, has been really helpful! i only have one question. One moving the emails, it is creating an error where it is copying the las email and duplicating it while moving. The error is: "The items were copied instead of moved because the original items cannot be deleted."Any ideas?

    • @izzyanalytics4145
      @izzyanalytics4145  2 ปีที่แล้ว

      Sometimes this happens if you have the email selected in the application.

  • @himitsudana
    @himitsudana 3 ปีที่แล้ว

    Is there any way to print out the attachment of MailItem?
    when i print out to CSV, it's show COM Object unknown

  • @adityabhardhwaj85
    @adityabhardhwaj85 3 ปีที่แล้ว

    Hi. Thanks for sharing knowledge. Could you please help me in how to automate shared mail box

  • @tariqpanjari1920
    @tariqpanjari1920 5 หลายเดือนก่อน

    Can you make a video on how to convert outlook emails in to HTML file using python

  • @abhinayarekar9958
    @abhinayarekar9958 3 ปีที่แล้ว

    Hi, Thank you for making this video. In one report mailbox we receive all mails with attachment. Sometimes senders forget to attach mail. How can filter for yesterday's mail which does not contain attachment

    • @mohamedbraham706
      @mohamedbraham706 3 ปีที่แล้ว +1

      import win32com.client as client
      import datetime
      today = datetime.date.today()
      delta = datetime.timedelta(days=1)
      outlook = client.Dispatch("outlook.application")
      ns = outlook.GetNameSpace("MAPI")
      inbox = ns.GetDefaultFolder(6)
      for email in inbox.items:
      myattachments = email.Attachments
      if email.ReceivedTime.date() >= (today-delta) and myattachments.count == 0:
      do something
      or check out this video for more informations: th-cam.com/video/iNmRyJwilxQ/w-d-xo.html

  • @rahulprasad7400
    @rahulprasad7400 3 ปีที่แล้ว

    Hello Lzzy,
    Good Evening,
    I need your help as I am totally fresher in Python but I have one assignment assigned my my teacher.
    The assignment is to create python script which can move outlook mails only when the condition and time matched.
    The condition is inside the mailbox if that mail contains "Rating..................Red" and the mail is comes in between from today 9 PM to morning 9 AM then move to a folder which is present in outlook named as "Ignore" and 2nd condition is if mail contains "Rating..................Red" but now the time is different like if mail comes in between from morning 9 AM to night 9 PM then move to folder "Ignore" which is already created in the outlook.
    Please help me .
    Thank you so much in Advance

  • @kingnate2653
    @kingnate2653 ปีที่แล้ว

    can someone please help me figure out how to do all this but for macOS system, I currently cant use the same import

  • @Doug-Didgiridoo
    @Doug-Didgiridoo ปีที่แล้ว

    thanks, very useful

  • @kivymdkorea4631
    @kivymdkorea4631 3 ปีที่แล้ว

    Good morning. I referenced the video to control Outlook with Python.
    But I have a problem, can I know which one is the problem?
    The problem is as follows:
    When printing the subject and contents of the mail in the inbox, the subject is displayed normally,
    but when printing the contents, the following error is finally displayed.
    ->"com_error: (-2147467259,'Unspecified error', None, None)"
    In Google search, I found the advice to untick the antivirus app in Option-addon-manager-Com addin.
    It doesn't seem right for me. How can I solve this problem?
    For reference, this is a problem in the company PC. The same code works fine at home.

  • @D_Wanderer
    @D_Wanderer 4 ปีที่แล้ว +1

    hello, I am trying to access inbox folder emails. It is only able to extract only some emails but not all, can you please tell why I am not getting all the emails and can you tell me how to get them all

    • @izzyanalytics4145
      @izzyanalytics4145  4 ปีที่แล้ว +1

      Can you send me an example of your code? I can't really say without seeing what your coffee looks like.

    • @D_Wanderer
      @D_Wanderer 4 ปีที่แล้ว

      @@izzyanalytics4145 import win32com.client as client
      outlook1 = client.Dispatch("Outlook.Application").GetNamespace("MAPI")
      account= outlook1.Folders["emailid"]
      print(account.Name)
      inbox = account.Folders["Inbox"]
      print(inbox.Name)
      Here I want to extract all the emails present in the inbox folder. But it is returning only some email. Basically it's not returning the emails which are obtained by clicking the click to view more in outlook available at the bottom of the emails

    • @izzyanalytics4145
      @izzyanalytics4145  4 ปีที่แล้ว

      Ok. So if I understand correctly... it's returning the emails that are in your Outlook client, but not the additional emails available and stored on the email server?

    • @D_Wanderer
      @D_Wanderer 4 ปีที่แล้ว

      @@izzyanalytics4145 i think that's exactly happening. can you please solve this issue

    • @izzyanalytics4145
      @izzyanalytics4145  4 ปีที่แล้ว

      Win32 can only work with emails that are on your local machine. It doesn't have access to anything on the server. You would either need to change your caching options to cache all the emails on the local machine, or use some kind of IMAP or SMPT access point. docs.microsoft.com/en-us/outlook/troubleshoot/installation/cached-exchange-mode

  • @pranayanmetiya8781
    @pranayanmetiya8781 3 ปีที่แล้ว

    Hi. I'm trying to get the sender email address, but for Exchange addresses the format is not what I want. I've been searching the net to get SMTP address but whatever I find did not work. Can you please look into it and find a solution? Thanks a lot.

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว

      You can access the sender email address with the SenderEmaikAddress property docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.senderemailaddress

    • @pranayanmetiya8781
      @pranayanmetiya8781 3 ปีที่แล้ว

      @@izzyanalytics4145 I'm doing that. But if the address is an Exchange address, the format is not the regular 'id@domain'. It's difficult to explain here, you will understand what I mean if you check yourself. Getting the SMTP address from Exchange accounts is where I'm stuck.

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว

      @@pranayanmetiya8781 can you give an example of what format it's in

    • @pranayanmetiya8781
      @pranayanmetiya8781 3 ปีที่แล้ว +1

      @@izzyanalytics4145 it's like this :
      /O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP(FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=6F467C825619482293F429C0BDE6F1DB-

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว

      I haven't found a clean way to do this yet. But, I'll let you know when I do. Essentially, you'll need to find a way to query the "GAL" to get the`PrimarySmtpAddress` on the ExchangeUser object. I'll let you know if I figure it out. Will you keep me posted as well in case you find the solution before I do.

  • @pranayanmetiya8781
    @pranayanmetiya8781 3 ปีที่แล้ว

    Hi. Can you please tell me how to get unread mails from Outlook account?

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว +1

      You can check the "UnRead" property docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.unread

    • @pranayanmetiya8781
      @pranayanmetiya8781 3 ปีที่แล้ว

      @@izzyanalytics4145 okay. Thanks a lot

    • @lucas.oliveira.pessoal
      @lucas.oliveira.pessoal 3 ปีที่แล้ว

      ​@@pranayanmetiya8781 I didnt understand how to do it. I would be like: message.Unread?

    • @lucas.oliveira.pessoal
      @lucas.oliveira.pessoal 3 ปีที่แล้ว

      @@izzyanalytics4145 I didnt understand how to do it. I would be like: message.Unread?

    • @pranayanmetiya8781
      @pranayanmetiya8781 3 ปีที่แล้ว

      @@lucas.oliveira.pessoal Yes. (message.UnRead) will return true or false, so checking the return value will inform you if the message selected in unread or not. Also you can set message.unRead = true/false if you want to change its status. P.S. sorry for late reply, as you can see I was working on this thing 7 months ago so I had to dig it up and study a little.

  • @alsotti1027
    @alsotti1027 3 ปีที่แล้ว

    Can You send an E-mail from that gmail account inside outlook?

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว

      yes, as long as you have your gmail connect to your outlook client.

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว

      github.com/israel-dryer/Outlook-Python-Tutorial/wiki/Send-mail-from-another-account

  • @sandeepal1
    @sandeepal1 3 ปีที่แล้ว

    @Izzy Thanks, this video helped me alot. Pls help to make video on how we can search mail based on specific keyword which is present in subject

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว

      This will be the same as searching the body except you will use the `Subject` property instead of `Body`

    • @sandeepal1
      @sandeepal1 3 ปีที่แล้ว

      @@izzyanalytics4145 Will it work for partial search? Example as below:
      Subject: New Item arrived.
      Want to search "Item" word only in subject and once found, perform the activity.

    • @izzyanalytics4145
      @izzyanalytics4145  3 ปีที่แล้ว +1

      @@sandeepal1 something like this will work: gist.github.com/israel-dryer/3cda283314dafde43e13872066db8f10

    • @sandeepal1
      @sandeepal1 3 ปีที่แล้ว

      @Izzy Analytics looking for help. I have 2 content in my outlook mail body and want to fetch specific one.
      Mail Body as below:
      Short Description: Abc
      Description: Abc def
      Want to fetch Description content only.
      Followed below approach but getting content for Short Description not for Description.
      Description = body_content.partition('Description: ') [2].splitlines()[0].split(':')
      Please help on this.

  • @rahulprasad7400
    @rahulprasad7400 3 ปีที่แล้ว

    Hello Lzzy,
    Good Evening,
    I need your help as I am totally fresher in Python but I have one assignment assigned my my teacher.
    The assignment is to create python script which can move outlook mails only when the condition and time matched.
    The condition is inside the mailbox if that mail contains "Rating..................Red" and the mail is comes in between from today 9 PM to morning 9 AM then move to a folder which is present in outlook named as "Ignore" and 2nd condition is if mail contains "Rating..................Red" but now the time is different like if mail comes in between from morning 9 AM to night 9 PM then move to folder "Ignore" which is already created in the outlook.
    Please help me .
    Thank you so much in Advance