473,289 Members | 1,959 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Email attachments and text

Section 12.2.13 (from the email module) gives examples of how to send
attachments with emails. The problem is, it does not explain how to
send text in the body of the message. One line of code that is gives
is:
outer.preamble = 'You will not see this in a MIME-aware mail
reader.\n'

So how do I arrange it so that the text *will* be seen?
Jul 18 '05 #1
2 1365
On Wed, Dec 10, 2003 at 08:25:35AM -0800, Mark Carter wrote:
Section 12.2.13 (from the email module) gives examples of how to send
attachments with emails. The problem is, it does not explain how to
send text in the body of the message. One line of code that is gives
is:
outer.preamble = 'You will not see this in a MIME-aware mail
reader.\n'

So how do I arrange it so that the text *will* be seen?


I recommend reading the documents linked from this page:

http://www.mhonarc.org/~ehood/MIME/

Once you have a solid understanding of MIME (particularly the multipart
type), using the email package should present no problems.

Jp

Jul 18 '05 #2
ca**********@ukmail.com (Mark Carter) wrote:
Section 12.2.13 (from the email module) gives examples of how to send
attachments with emails. The problem is, it does not explain how to
send text in the body of the message. One line of code that is gives
is:
outer.preamble = 'You will not see this in a MIME-aware mail
reader.\n'

So how do I arrange it so that the text *will* be seen?


a snippet of my code, i've add the html as plain text as well. STrip the
html codes are you're done.
All this is email body work, nothing else.
This seems to work, even with Outlook (and others :] )
self.msgbody = "Date: " +time.strftime("%a, %d %b %Y %H:%M:%S
+0100", time.gmtime()) + '\r\n'
self.msgbody += "Subject: " +subject+ '\r\n'
self.msgbody += "From: " +self.fr+ '\r\n'
self.msgbody += "To: "+self.to + '\r\n'
self.msgbody += "Sender: me@mydomain.com" + '\r\n'
self.msgbody += "Content-Type: multipart/alternative;
boundary=SEPERATORLINEWICHSHOULDNEVEROCCURINREALTE XT" + '\r\n'
self.msgbody += "MIME-Version: 1.0" + '\r\n\r\n'
self.msgbody += """
--SEPERATORLINEWICHSHOULDNEVEROCCURINREALTEXT
Content-Type: text/plain

%(textbody)s

--SEPERATORLINEWICHSHOULDNEVEROCCURINREALTEXT
Content-Type: text/html

<html>%(htmlbody)s</html>

--SEPERATORLINEWICHSHOULDNEVEROCCURINREALTEXT--
""" % {'textbody':body,'htmlbody':body}

gr.
Remco
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SimonC | last post by:
I've done a couple of hours web-searching without turning up many answers so far, and I guess I could figure it out (eventually) from the MIME format, but here goes with my question... I don't...
4
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it...
3
by: LutherRevisited | last post by:
Is there a way I can put a message together without having to download any attachments there may be at the same time. I'm not having any problems dealing with attachments, but the way I'm doing...
5
by: morphex | last post by:
Hi, I have an email that's in the utf-8 encoding, and I'm getting this error message when I try to send it using smtplib: * Module smtplib, line 688, in sendmail * Module smtplib, line 485,...
4
by: Russell Bungay | last post by:
Hello all, I have written a short function, based on a recipe in the Python Cookbook, that sends an e-mail. The function takes arguments that define who the e-mail is to, from, the subject, the...
6
by: chris_fieldhouse | last post by:
Hi, I have a script for processing emails, The script finds email sent to a particular alias, grabs the body text of the email and stores it into a database. Problem is that certain character...
0
by: YYZ | last post by:
Problem: I need to allow my users to drag an email out of Outlook and drop it on a winform -- from there, I need to get the text of that email (not just the sender and subject) -- from there I'll...
10
by: OdAwG | last post by:
Hello All, Is it possible to send an email from Access? I found a Microsoft article on how to do this but I keep getting an error "RUNTIME ERROR 438" -- Object doesn't support this property or...
2
by: oyster | last post by:
I find that the existing email moudle is some hard for me to understand, especially the part of how to set the CC, BCC and attach the files. Is there any more easy one like this p-code? import...
1
by: budyerr | last post by:
All, I am trying to build a email submission form using asp.net. I currently have a web form page that will upload to my webhosting server, attach to email then delete the file after sending. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.