2

is this problem because of line: mail = outlook.CreateItem(0)? i want to send n e-mails in for loop in python.

for aaa in jira.search_issues(JQL,startAt=0, maxResults=50):
    print(aaa)
    try:
        tworca = (jira.issue(aaa).fields.creator.name)
        przypisany =(jira.issue(aaa).fields.assignee.name)
        import win32com.client as win32
        outlook = win32.Dispatch('outlook.application')
        mail = outlook.CreateItem(0)
        mail.To = tworca + ';' + przypisany
        mail.Subject = 'blablabla'
        mail.Body = 'Message body'
        mail.send()
        print ("OK!")
    except Exception as e:
        print("ERROR: " + str(e))

print ("done!")

traceback:

Traceback (most recent call last):
  File "C:\xxx\xxx\xxx\xxx.py", line 12, in <module>
    mail.send()
TypeError: 'bool' object is not callable
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
ti01878
  • 483
  • 1
  • 5
  • 18

2 Answers2

5

You are looking for mail.Send(). mail.send is a bool object.

Remember Python is case sensitive.

See relevant: Send Outlook Email Via Python?

Another tip: don't assume how your code work like "there's no bool object". The traceback is never wrong and is the best starting point to tell you where you should begin your investigation. It can be a typo or simple misuse of attribute. In this case, clearly the interpreter is telling you mail.send is not what you expect it to be.

r.ook
  • 13,466
  • 2
  • 22
  • 39
0

I got the same error as you:

mail.send() TypeError: 'bool' object is not callable".

I changed the code from mail.send() to mail.send, and the problem was solved.

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
  • Welcome aboard. Keep in mind that proper capitalisation, grammar, spelling, et al, is important. You can read more details about SO guidelines for posts in the help section from a link on the nav bar. Also please use markdown (or the editing menu) to format code & error messages as such. Looking forward to seeing more of your contributions. – SherylHohman Dec 25 '21 at 22:15