#๐Ÿ”’ Does anyone know how to fix this error?

47 messages ยท Page 1 of 1 (latest)

pale haloBOT
#

@odd slate

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

tame osprey
#

!pastebin the error message if its too long @odd slate

pale haloBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

odd slate
#

File "C:\Users\gregaryb\AppData\Local\Programs\Python\Python312\Lib\email\generator.py", line 115, in flatten
self._write(msg)
File "C:\Users\gregaryb\AppData\Local\Programs\Python\Python312\Lib\email\generator.py", line 180, in _write
self._dispatch(msg)
File "C:\Users\gregaryb\AppData\Local\Programs\Python\Python312\Lib\email\generator.py", line 217, in _dispatch
meth(msg)
File "C:\Users\gregaryb\AppData\Local\Programs\Python\Python312\Lib\email\generator.py", line 275, in _handle_multipart
g.flatten(part, unixfrom=False, linesep=self._NL)
File "C:\Users\gregaryb\AppData\Local\Programs\Python\Python312\Lib\email\generator.py", line 106, in flatten
old_msg_policy = msg.policy
^^^^^^^^^^
AttributeError: 'str' object has no attribute 'policy'

tame osprey
#

msg is a string

#

is it supposed to be a dict or something?

odd slate
#

SMTPObject.sendmail(strFromEmail, strEmail, RootEmailMsg.as_string())

RootEmailMsg.as_string() is causing it.

tame osprey
#

maybe don't set it as a string?

#

You can't upload files here

#

!pastebin your code

pale haloBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

odd slate
#

Tried that - that causes a different error

tame osprey
odd slate
#

If I could figure out how to put my code in here I would.

tame osprey
odd slate
#

Discord is being a pain in the arse

#

What pastebin? Where?

tame osprey
odd slate
#

So what do I do with that?

tame osprey
#

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

odd slate
#

I hate it when programmers try to do fancy stuff and end up making a damn nuisance of themselves.

#

Ctrl S from where for god's sake?

tame osprey
#

If you just hit CTRL + S on that page, the page URL will change to something else

#

Copy that URL and paste it here

odd slate
#

How's that?

tame osprey
#

better

odd slate
#

Why can't you just paste a small amount of code in the post rather than go through that rigmaroll!

tame osprey
tame osprey
#

And make sure to use the Discord code format for better readability

odd slate
#

It wouldn't let me do it.

#

RootEmailMsg.as_string() That causes the error

#

So what am I doing wrong with setting up RootEmailMsg in that code?

tame osprey
#

What happens if you take away .as_string()?

odd slate
#

Get a different error

tame osprey
#

Can I see it?

tame osprey
odd slate
#

File "C:\Users\gregaryb\AppData\Local\Programs\Python\Python312\Lib\smtplib.py", line 177, in quote_periods
return re.sub(br'(?m)^.', b'..', bindata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\gregaryb\AppData\Local\Programs\Python\Python312\Lib\re_init
.py", line 186, in sub
return _compile(pattern, flags).sub(repl, string, count)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'MIMEMultipart'

tame osprey
#

I see

#

Yeah its supposed to send as_string()

#

So that's not where the problem is

odd slate
tame osprey
#

No idea sorry

pale haloBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.