List Icon
Archiv Mailingliste

2019 bis Juli 2022  2018  | 2017 2016 2015 | 2014 | 2013

Die Mailingliste ist seit Juli 2022 geschlossen, dient aber weiterhin als Informationsarchiv zu QF-Test.
Wenn Sie aber über Neuerungen zu QF-Test informiert bleiben wollen, können Sie einfach unseren
Newsletter abonnieren

Um aktuell die Informationen zu jeder Release - auch Minor Releases - zu bekommen, können Sie den
RSS-Feed abonnieren oder uns in sozialen Medien folgen.
Alternativ bietet QF-Test auch selbst eine Versionsinformation an.

Eine weitere Informationsquelle ist unser Blog, in dem es aktuelle Beiträge zu allgemeinen Themen, zur Firma QFS und auch diverse "How-Tos" gibt:
Blog abonnieren


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[QF-Test] How to send email with an attachment.


  • Subject: [QF-Test] How to send email with an attachment.
  • From: "Sadiku, Adetola" <Tola.Sadiku@?.com>
  • Date: Sat, 18 Jun 2016 14:48:53 +0000

Hello,

Can someone please assist me with a working script or directions that will allow the QFTest sendEmail script to include an attachment.

I have done some research and tried to modify the jython script for the sendEmail_SMTPHost procedure but getting errors. It will be nice if there is an easier way to do this without needing to write code.

 

Please find attached my edited jython server script.

 

 

Thank you,

Tola Sadiku, MSC, CSM | Quality Assurance Analyst

Certified Scrum Master

AmeriPride Services

10801 Wayzata Boulevard, Minnetonka

Minnesota, MN 55305

O: 952-738-3232

F: 952-738-3158

tola.sadiku@?.com

www.ameripride.com

People You Can Count On

Click here to submit a ticket!

  

___________________________________________________________________________________________________

"Good manners will open doors that the best education cannot” – Clarence Thomas 

 

import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
from os.path import basename
from email.mime.application import MIMEApplication

smtpHost = rc.lookup("smtpHost")
smtpUser = rc.lookup("smtpUser")
smtpPassword = rc.lookup("smtpPassword")
asHtml = rc.getBool("asHtml")

addstr = rc.lookup("to")
addarray= addstr.split(",")

addresses = []
for a in addarray:
    addresses.append(a.strip())

msg = MIMEMultipart()
msg['From'] = rc.lookup("from")
msg['Subject'] = rc.lookup("subject")
msg['To'] = ",".join(addresses)

if asHtml:
    msg = MIMEText(rc.lookup("text"),"html")
else:
    msg = MIMEText(rc.lookup("text"),"plain")    

part = MIMEBase('application', "octet-stream")
part.set_payload(open("text.txt", "rb").read())
Encoders.encode_base64(part)

part.add_header('Content-Disposition', 'attachment; filename="text.txt"')

msg.attach(part)

# Send the message via SMTP server, but don't include the
# envelope header.

s = smtplib.SMTP(smtpHost)

if smtpUser != '': #only perform login, if user is specified
    s.login(smtpUser, smtpPassword)


s.sendmail(rc.lookup("from"), addresses, msg.as_string())
s.quit()