473,395 Members | 1,471 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,395 software developers and data experts.

Sending an email using smtp lib with body containing multiple lines and variables

2
I have cracked sending an email containing text and a value from a variable using some code I found online
Expand|Select|Wrap|Line Numbers
  1. SERVER = "server"
  2.  
  3. FROM = "from address"
  4. TO = ["to address"]
  5. SUBJECT = "subject"
  6.  
  7. TEXT = "Line Count     :- " + str(linecount)
  8.  
  9. # Prepare actual message
  10.  
  11. message = """\
  12. From: %s
  13. To: %s
  14. Subject: %s
  15.  
  16. %s
  17. """ % (FROM, ", ".join(TO), SUBJECT, TEXT)
  18.  
  19. server = smtplib.SMTP(SERVER)
  20. server.sendmail(FROM, TO, message)
  21. server.quit()
However I would like to add extra lines for other totals. I don't seem to be able to figure out how to do this.

Any help would be greatly appreciated.
Aug 13 '14 #1
2 2514
bvdet
2,851 Expert Mod 2GB
Here is one possibility:
Expand|Select|Wrap|Line Numbers
  1. >>> ("Line Count     :- %s\n"
  2. ...  "another line count: %s" % (linecount, linecount*2))
  3. 'Line Count     :- 6\nanother line count: 12'
  4. >>> print ("Line Count     :- %s\n"
  5. ...     "another line count: %s" % (linecount, linecount*2))
  6. Line Count     :- 6
  7. another line count: 12
  8. >>> 
Aug 13 '14 #2
pd4860
2
Thanks - that did the required job
Aug 14 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: James | last post by:
How can I take my form data and send it as an email using my SMTP server located @ my ISP using PHP ? my form has several fields: TO: this is a drop down list FROM: this is a drop down...
6
by: Robert Pettersson | last post by:
Hi, I have built an webapp in C# that uses SMTPMail to send mail to users. When I installed it on the prodserver everything worked fine for me, but the users can not send mail. They get Access...
3
by: Srinivas | last post by:
Hi, I am using ASP.NET SmtpMail to send email using the following code public void SendEmail(string From, string To, string Subject, StringBuilder Message, string Attachment, string...
6
by: lalit26011983 | last post by:
Can any1 help me... How to send emails using asp.net.. I m using windows 2000 server and visual studio 2003(.net framework 1.1) I m not getting any error while i m sending email using...
0
by: bhargavigupta | last post by:
hi, In my application i am using smtp server for sending mails i rote the host name,port in the web.config file like this <configuration> <configSections> <sectionGroup name...
3
by: shansivamani | last post by:
using SMTP to send email. is there any settings need to be configured apart from Host name and Port, while sending emails using SMTPClient in .Net? when i try to send mail to ids which has only...
0
by: trivedimca2005 | last post by:
I am using below code for sending Email using .net. Its not working on client machine. My server IP is:- 192.168.10.10 and also uses proxy and user-name and password for proxy settings are...
6
by: Chocolade | last post by:
Hi, Im using System.Net.Mail to send email in my application it was working great without any problems untill this morning after like 20-30 tries it was sending the email ok then suddenly this...
1
India777
by: India777 | last post by:
Hai all, I got the Following Error When Sending Email to Live Address using SMTP in c#. Error Details: System.Net.WebException: Unable to connect to the remote server --->...
1
by: immohito | last post by:
Hi I am going crazy trying to send an email using XAMPP, my php form on my localhost server. This is the email section of the code if($insert_result) { ini_set('SMTP',...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.