OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Python 3.x email.message library: trying to remove specific header content such as bcc

  • Thread starter Thread starter tuck1s
  • Start date Start date
T

tuck1s

Guest
The library functions for reading headers from an RFC822 compliant file are working just fine for me, for example:

Code:
    allRecips = []
    for hdrName in ['to', 'cc', 'bcc']:
        for i in email.utils.getaddresses(msg.get_all(hdrName, [])):
            r = {
                'address': {
                    'name': i[0],
                    'email': i[1]
                }
            }
            allRecips.append(r)

I now want to remove the bcc recipients from the msg structure in the above example. I looked at del_param() for this, but couldn't figure out what to pass in. Is there a good way to delete any bcc headers that may be present (1 or more)?
<p>The <a href="https://docs.python.org/3/library/email.message.html#email.message.EmailMessage" rel="nofollow noreferrer">library</a> functions for reading headers from an RFC822 compliant file are working just fine for me, for example:</p>
<pre><code> allRecips = []
for hdrName in ['to', 'cc', 'bcc']:
for i in email.utils.getaddresses(msg.get_all(hdrName, [])):
r = {
'address': {
'name': i[0],
'email': i[1]
}
}
allRecips.append(r)
</code></pre>
<p>I now want to remove the bcc recipients from the <code>msg</code> structure in the above example. I looked at <code>del_param()</code> for this, but couldn't figure out what to pass in.
Is there a good way to delete any bcc headers that may be present (1 or more)?</p>
Continue reading...
 

Latest posts

Top