In my script, User fills a Django form then two things : data are saved in my database and an email is sent to a support account.
I'm looking for improve this little part from my Django web application. All this process works fine, but I would like to improve this part in my view :
subject = "Ticket n° " + str(post.id) + " : " + str(post.Objet.encode('utf-8'))
message = "Bonjour Datasystems, \n \n Vous avez un nouveau ticket en attente comportant les informations suivantes : \n " + "Nom : " + str(post.Nom.encode('utf-8')) + " \n Prénom : " + str(post.Prenom.encode('utf-8')) + " \n Société/Association client : " + str(request.user.last_name.encode("utf-8")) + " \n N° Téléphone : " + str(post.Telephone.encode("utf-8")) + " \n Adresse Email : " + str(post.Mail.encode("utf-8")) + " \n Description du problème : " + str(post.Description.encode("utf-8"))
image = post.Image
mail = EmailMessage(subject, message, 'support@datasystems.fr', ['support@datasystems.fr'], html_message='This is <b>HTML</b> Content')
mail.attach_file(image.path)
mail.send()
I would like to write this part with bold character before each variable.
For example in my email :
- Nom : test (currently)
- Nom : test (What I would like to get)
And make vertical space where I put both \n
:
For example :
Bonjour Datasystems,
Vous avez un nouveau ticket ... (currently)
---
Bonjour Datasystems,
Vous avez un nouveau ticket ... (What I would like to get)
Up to now, my email looks like this :
Do you have any solution according to my both issues ?